-
Notifications
You must be signed in to change notification settings - Fork 1
Sourcery Starbot ⭐ refactored greencrab/pandas #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sourcery timed out performing refactorings.
Due to GitHub API limits, only the first 60 comments can be shown.
@@ -6,6 +6,7 @@ | |||
BSD license. Parts are from lxml (https://github.com/lxml/lxml) | |||
""" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 42-57
refactored with the following changes:
- Replace interpolated string formatting with f-string [×4] (
replace-interpolation-with-fstring
)
if hasattr(ext, 'include_dirs') and not numpy_incl in ext.include_dirs: | ||
if hasattr(ext, 'include_dirs') and numpy_incl not in ext.include_dirs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function build_ext.build_extensions
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
for d in dirs: | ||
if d == '__pycache__': | ||
self._clean_trees.append(pjoin(root, d)) | ||
|
||
self._clean_trees.extend(pjoin(root, d) for d in dirs if d == '__pycache__') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function CleanCommand.initialize_options
refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend
)
cfile = pyxfile[:-3] + 'c' | ||
msg = "C-source file '%s' not found." % (cfile) +\ | ||
" Run 'setup.py cython' before sdist." | ||
cfile = f'{pyxfile[:-3]}c' | ||
msg = f"C-source file '{cfile}' not found. Run 'setup.py cython' before sdist." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function CheckSDist.run
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
repl = 'macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64' | ||
if tag[2] == 'macosx_10_6_intel': | ||
repl = 'macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function BdistWheel.get_tag
refactored with the following changes:
- Move assignments closer to their usage (
move-assign
)
if "+" in pieces.get("closest-tag", ""): | ||
return "." | ||
return "+" | ||
return "." if "+" in pieces.get("closest-tag", "") else "+" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function plus_or_dot
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
)
if pieces["dirty"]: | ||
rendered += ".dirty" | ||
else: | ||
# exception #1 | ||
rendered = "0+untagged.%d.g%s" % (pieces["distance"], | ||
pieces["short"]) | ||
if pieces["dirty"]: | ||
rendered += ".dirty" | ||
if pieces["dirty"]: | ||
rendered += ".dirty" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function render_pep440
refactored with the following changes:
- Hoist conditional out of nested conditional (
hoist-if-from-if
) - Hoist repeated code outside conditional statement (
hoist-statement-from-if
)
rendered += "g%s" % pieces["short"] | ||
rendered += f'g{pieces["short"]}' | ||
else: | ||
# exception #1 | ||
rendered = "0.post%d" % pieces["distance"] | ||
if pieces["dirty"]: | ||
rendered += ".dev0" | ||
rendered += "+g%s" % pieces["short"] | ||
rendered += f'+g{pieces["short"]}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function render_pep440_post
refactored with the following changes:
- Replace interpolated string formatting with f-string [×2] (
replace-interpolation-with-fstring
)
if pieces["dirty"]: | ||
rendered += ".dev0" | ||
else: | ||
# exception #1 | ||
rendered = "0.post%d" % pieces["distance"] | ||
if pieces["dirty"]: | ||
rendered += ".dev0" | ||
if pieces["dirty"]: | ||
rendered += ".dev0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function render_pep440_old
refactored with the following changes:
- Hoist conditional out of nested conditional (
hoist-if-from-if
) - Hoist repeated code outside conditional statement (
hoist-statement-from-if
)
raise ValueError("unknown style '%s'" % style) | ||
raise ValueError(f"unknown style '{style}'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function render
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
assert handlers, "unrecognized VCS '%s'" % cfg.VCS | ||
assert handlers, f"unrecognized VCS '{cfg.VCS}'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function get_versions
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Replace interpolated string formatting with f-string [×5] (
replace-interpolation-with-fstring
)
cmds = {} | ||
|
||
# we add "version" to both distutils and setuptools | ||
from distutils.core import Command | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function get_cmdclass
refactored with the following changes:
- Move assignment closer to its usage within a block [×2] (
move-assign-in-block
) - Replace interpolated string formatting with f-string [×7] (
replace-interpolation-with-fstring
) - Merge dictionary assignment with declaration [×2] (
merge-dict-assign
)
print(" creating %s" % cfg.versionfile_source) | ||
print(f" creating {cfg.versionfile_source}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function do_setup
refactored with the following changes:
- Replace interpolated string formatting with f-string [×5] (
replace-interpolation-with-fstring
)
for line in f.readlines(): | ||
for line in f: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function scan_setup_py
refactored with the following changes:
- Iterate over files directly rather than using readlines() (
use-file-iterator
)
output = 'class {}(object):\n'.format(bench.name) | ||
output = f'class {bench.name}(object):\n' | ||
output += tab + 'goal_time = 0.2\n\n' | ||
|
||
if bench.setup: | ||
indented_setup = [tab * 2 + '{}\n'.format(x) for x in bench.setup.splitlines()] | ||
indented_setup = [tab * 2 + f'{x}\n' for x in bench.setup.splitlines()] | ||
output += tab + 'def setup(self):\n' + ''.join(indented_setup) + '\n' | ||
|
||
for kind in kinds: | ||
output += tab + 'def {}_{}(self):\n'.format(kind, bench.name) | ||
output += f'{tab}def {kind}_{bench.name}(self):\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function vbench_to_asv_source
refactored with the following changes:
- Replace call to format with f-string [×3] (
use-fstring-for-formatting
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.data = (self.data * 200) | ||
self.data *= 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function read_csv_precise_converter.setup
refactored with the following changes:
- Replace assignment with augmented assignment (
aug-assign
)
self.data = (self.data * 200) | ||
self.data *= 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function read_csv_roundtrip_converter.setup
refactored with the following changes:
- Replace assignment with augmented assignment (
aug-assign
)
self.data = (self.data * 200) | ||
self.data *= 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function read_table_multiple_date.setup
refactored with the following changes:
- Replace assignment with augmented assignment (
aug-assign
)
self.data = (self.data * 200) | ||
self.data *= 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function read_table_multiple_date_baseline.setup
refactored with the following changes:
- Replace assignment with augmented assignment (
aug-assign
)
self.to_rep = dict(((i, (self.start_value + i)) for i in range(self.n))) | ||
self.to_rep = {i: self.start_value + i for i in range(self.n)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function replace_large_dict.setup
refactored with the following changes:
- Replace list(), dict() or set() with comprehension (
collection-builtin-to-comprehension
)
for iter in range(10): | ||
for _ in range(10): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function unstack_sparse_keyspace.setup
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
for i in range(100): | ||
for _ in range(100): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 21-21
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
ret = table.factorize(df['A']) | ||
return ret | ||
return table.factorize(df['A']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function f
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
ret = table.factorize(df['A']) | ||
return ret | ||
return table.factorize(df['A']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function g
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if len(panels) == 0: | ||
if not panels: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function create_panels_append
refactored with the following changes:
- Simplify sequence length comparison (
simplify-len-comparison
) - Replace interpolated string formatting with f-string [×2] (
replace-interpolation-with-fstring
)
key='KEY.%s.%s' %(os.environ.get('TRAVIS_REPO_SLUG','unk'), | ||
os.environ.get('JOB_NAME','unk')) | ||
key = f"KEY.{os.environ.get('TRAVIS_REPO_SLUG', 'unk')}.{os.environ.get('JOB_NAME', 'unk')}" | ||
|
||
key='KEY.%s.%s' %(os.environ.get('TRAVIS_REPO_SLUG','unk'), | ||
os.environ.get('JOB_NAME','unk')) | ||
key = f"KEY.{os.environ.get('TRAVIS_REPO_SLUG', 'unk')}.{os.environ.get('JOB_NAME', 'unk')}" | ||
print(key) | ||
|
||
if sys.version_info[0] > 2: | ||
key = bytes(key,encoding='utf8') | ||
|
||
key = sha1(key).hexdigest()[:8]+'.' | ||
key = f'{sha1(key).hexdigest()[:8]}.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 13-48
refactored with the following changes:
- Replace interpolated string formatting with f-string [×4] (
replace-interpolation-with-fstring
) - Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
) - Remove unreachable code (
remove-unreachable-code
)
local_dir = doc_root + 'build/html' | ||
remote_dir = '/usr/share/nginx/pandas/pandas-docs/version/%s/' % ver | ||
local_dir = f'{doc_root}build/html' | ||
remote_dir = f'/usr/share/nginx/pandas/pandas-docs/version/{ver}/' | ||
cmd = 'cd %s; rsync -avz . %s@pandas.pydata.org:%s -essh' | ||
cmd = cmd % (local_dir, user, remote_dir) | ||
cmd %= (local_dir, user, remote_dir) | ||
print(cmd) | ||
if os.system(cmd): | ||
raise SystemExit( | ||
'Upload to %s from %s failed' % (remote_dir, local_dir)) | ||
raise SystemExit(f'Upload to {remote_dir} from {local_dir} failed') | ||
|
||
local_dir = doc_root + 'build/latex' | ||
local_dir = f'{doc_root}build/latex' | ||
pdf_cmd = 'cd %s; scp pandas.pdf %s@pandas.pydata.org:%s' | ||
pdf_cmd = pdf_cmd % (local_dir, user, remote_dir) | ||
pdf_cmd %= (local_dir, user, remote_dir) | ||
if os.system(pdf_cmd): | ||
raise SystemExit('Upload PDF to %s from %s failed' % (ver, doc_root)) | ||
raise SystemExit(f'Upload PDF to {ver} from {doc_root} failed') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function upload_prev
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
) - Replace interpolated string formatting with f-string [×3] (
replace-interpolation-with-fstring
) - Replace assignment with augmented assignment [×2] (
aug-assign
)
if os.system('git checkout v%s' % ver) != 1: | ||
if os.system(f'git checkout v{ver}') != 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function build_prev
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
@@ -164,7 +163,6 @@ def latex_forced(): | |||
os.system('pdflatex -interaction=nonstopmode pandas.tex') | |||
raise SystemExit("You should check the file 'build/latex/pandas.pdf' for problems.") | |||
|
|||
os.chdir('../..') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function latex_forced
refactored with the following changes:
- Remove unreachable code (
remove-unreachable-code
)
sendmail(step, '[ERROR] ' + msg) | ||
sendmail(step, f'[ERROR] {msg}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function auto_dev_build
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run: