Commit 2c0d2c43 authored by Aksh Gupta's avatar Aksh Gupta Committed by Godefroid Chapelle

chore: refactor code quality issues

- Refactor complex statement to use if expression.
- Fix dangerous default argument.
- Remove unused imports and reimported modules.
- Refactor unnecessary use of list comprehension.
- Add .deepsource.toml file for continuous analysis on bug risks/performance/code-quality issues on new changes.
parent a7e4ad61
version = 1
test_patterns = [
"zc.recipe.egg_/src/zc/recipe/egg/tests.py",
"src/zc/buildout/tests/**"
]
exclude_patterns = ["builds/**"]
[[analyzers]]
name = "python"
enabled = true
[analyzers.meta]
runtime_version = "3.x.x"
\ No newline at end of file
......@@ -25,7 +25,7 @@ if sys.version_info > (3, ) and sys.version_info < (3, 5):
raise SystemError("No support for Python 3.x under 3.5.")
import os, shutil, sys, subprocess, tempfile
import os, shutil, subprocess, tempfile
for d in 'eggs', 'develop-eggs', 'bin', 'parts':
if not os.path.exists(d):
......
......@@ -80,8 +80,10 @@ class Download(object):
"""
def __init__(self, options={}, cache=-1, namespace=None,
def __init__(self, options=None, cache=-1, namespace=None,
offline=-1, fallback=False, hash_name=False, logger=None):
if options is None:
options = {}
self.directory = options.get('directory', '')
self.cache = cache
if cache == -1:
......
......@@ -1742,7 +1742,7 @@ def make_egg_after_pip_install(dest, distinfo_dir):
shutil.rmtree(bin_dir)
# Make properly named new egg dir
distro = [d for d in pkg_resources.find_distributions(dest)][0]
distro = list(pkg_resources.find_distributions(dest))[0]
egg_name = distro.egg_name() + '.egg'
egg_dir = os.path.join(dest, egg_name)
os.mkdir(egg_dir)
......
......@@ -621,7 +621,6 @@ def run_buildout(command):
# Make sure we don't get .buildout
os.environ['HOME'] = os.path.join(os.getcwd(), 'home')
args = command.split()
import pkg_resources
buildout = pkg_resources.load_entry_point(
'zc.buildout', 'console_scripts', args[0])
buildout(args[1:])
......
......@@ -30,7 +30,7 @@ def create_sample_eggs(test, executable=sys.executable):
for i in (0, 1, 2):
write(tmp, 'eggrecipedemoneeded.py', 'y=%s\ndef f():\n pass' % i)
rc1 = i==2 and 'rc1' or ''
rc1 = 'rc1' if i==2 else ''
write(
tmp, 'setup.py',
"from setuptools import setup\n"
......@@ -81,7 +81,7 @@ def create_sample_eggs(test, executable=sys.executable):
'def main():\n'
' print_(x, eggrecipedemoneeded.y)\n'
% i)
rc1 = i==4 and 'rc1' or ''
rc1 = 'rc1' if i==4 else ''
write(
tmp, 'setup.py',
"from setuptools import setup\n"
......@@ -175,7 +175,7 @@ MOD_INIT(extdemo)
}
"""
extdemo_c = sys.version_info[0] < 3 and extdemo_c2 or extdemo_c3
extdemo_c = extdemo_c2 if sys.version_info[0] < 3 else extdemo_c3
extdemo_setup_py = r"""
import os, sys
......
......@@ -384,7 +384,9 @@ setup(name=%r, version=%r,
)
"""
def make_dist_that_requires(dest, name, requires=[], version=1, egg=''):
def make_dist_that_requires(dest, name, requires=None, version=1, egg=''):
if requires is None:
requires = []
os.mkdir(os.path.join(dest, name))
with open(os.path.join(dest, name, 'setup.py'), 'w') as f:
f.write(
......
......@@ -15,10 +15,8 @@
"""
import copy
import glob
import logging
import os
import pkg_resources
import re
import sys
import zc.buildout.easy_install
......
......@@ -16,8 +16,6 @@ from zope.testing import renormalizing
import doctest
import os
import re
import shutil
import sys
import zc.buildout.tests
import zc.buildout.testing
from zc.buildout import WINDOWS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment