Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SourceryAI
Copy link

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:

git fetch https://github.com/sourcery-ai-bot/pandas master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Copy link
Author

@SourceryAI SourceryAI left a 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)
"""

Copy link
Author

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:

Comment on lines -91 to +96
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:
Copy link
Author

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)

Comment on lines -226 to +231
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__')
Copy link
Author

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:

Comment on lines -283 to +286
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."
Copy link
Author

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:

Comment on lines -338 to +340
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'
Copy link
Author

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:

Comment on lines -1170 to +1158
if "+" in pieces.get("closest-tag", ""):
return "."
return "+"
return "." if "+" in pieces.get("closest-tag", "") else "+"
Copy link
Author

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:

Comment on lines -1188 to +1179
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"
Copy link
Author

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:

Comment on lines -1231 to +1221
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"]}'
Copy link
Author

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:

Comment on lines -1251 to +1239
if pieces["dirty"]:
rendered += ".dev0"
else:
# exception #1
rendered = "0.post%d" % pieces["distance"]
if pieces["dirty"]:
rendered += ".dev0"
if pieces["dirty"]:
rendered += ".dev0"
Copy link
Author

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:

Comment on lines -1321 to +1303
raise ValueError("unknown style '%s'" % style)
raise ValueError(f"unknown style '{style}'")
Copy link
Author

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:

Comment on lines -1343 to +1325
assert handlers, "unrecognized VCS '%s'" % cfg.VCS
assert handlers, f"unrecognized VCS '{cfg.VCS}'"
Copy link
Author

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:

Comment on lines -1424 to +1408
cmds = {}

# we add "version" to both distutils and setuptools
from distutils.core import Command


Copy link
Author

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:

Comment on lines -1591 to +1583
print(" creating %s" % cfg.versionfile_source)
print(f" creating {cfg.versionfile_source}")
Copy link
Author

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:

Comment on lines -1663 to +1656
for line in f.readlines():
for line in f:
Copy link
Author

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:

Comment on lines -14 to +22
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'
Copy link
Author

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:

self.data = (self.data * 200)
self.data *= 200
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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)}
Copy link
Author

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:

for iter in range(10):
for _ in range(10):
Copy link
Author

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:

for i in range(100):
for _ in range(100):
Copy link
Author

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:

ret = table.factorize(df['A'])
return ret
return table.factorize(df['A'])
Copy link
Author

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:

Comment on lines -31 to +30
ret = table.factorize(df['A'])
return ret
return table.factorize(df['A'])
Copy link
Author

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:

if len(panels) == 0:
if not panels:
Copy link
Author

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:

Comment on lines -13 to +21
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]}.'
Copy link
Author

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:

Comment on lines -64 to +76
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')
Copy link
Author

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:

Comment on lines -86 to +85
if os.system('git checkout v%s' % ver) != 1:
if os.system(f'git checkout v{ver}') != 1:
Copy link
Author

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:

@@ -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('../..')
Copy link
Author

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:

Comment on lines -209 to +207
sendmail(step, '[ERROR] ' + msg)
sendmail(step, f'[ERROR] {msg}')
Copy link
Author

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant