Skip to content
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

Sourcery Starbot ⭐ refactored programmer290399/pyqna #22

Open
wants to merge 1 commit into
base: main
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 main branch, then run:

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

extra_deps["all"] = set(vv for v in extra_deps.values() for vv in v)
extra_deps["all"] = {vv for v in extra_deps.values() for vv in v}
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_extra_requires refactored with the following changes:

python_requires=">={}".format(".".join(str(n) for n in min_version)),
python_requires=f'>={".".join(str(n) for n in min_version)}',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 75-75 refactored with the following changes:

"Warning: build in %s is using versioneer.py from %s"
% (os.path.dirname(me), versioneer_py)
f"Warning: build in {os.path.dirname(me)} is using versioneer.py from {versioneer_py}"
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_root refactored with the following changes:

Comment on lines -412 to +424
print("unable to run %s" % dispcmd)
print(f"unable to run {dispcmd}")
print(e)
return None, None
else:
if verbose:
print("unable to find command, tried %s" % (commands,))
print(f"unable to find command, tried {commands}")
return None, None
stdout = p.communicate()[0].strip()
if sys.version_info[0] >= 3:
stdout = stdout.decode()
if p.returncode != 0:
if verbose:
print("unable to run %s (error)" % dispcmd)
print("stdout was %s" % stdout)
print(f"unable to run {dispcmd} (error)")
print(f"stdout was {stdout}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function run_command refactored with the following changes:

Comment on lines -964 to +973
f = open(versionfile_abs, "r")
for line in f.readlines():
if line.strip().startswith("git_refnames ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["refnames"] = mo.group(1)
if line.strip().startswith("git_full ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["full"] = mo.group(1)
if line.strip().startswith("git_date ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["date"] = mo.group(1)
f.close()
with open(versionfile_abs, "r") as f:
for line in f:
if line.strip().startswith("git_refnames ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["refnames"] = mo[1]
if line.strip().startswith("git_full ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["full"] = mo[1]
if line.strip().startswith("git_date ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["date"] = mo[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 git_get_keywords refactored with the following changes:

Comment on lines -1426 to +1398
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 -1455 to +1427
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 -1544 to +1518
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:

This removes the following comments ( why? ):

#   "version": versioneer.get_version().split("+", 1)[0], # FILEVERSION
# nczeczulin reports that py2exe won't like the pep440-style string
# as FILEVERSION, but it can be used for PRODUCTVERSION, e.g.
#   "product_version": versioneer.get_version(),
#   ...
# setup(console=[{

Comment on lines -1770 to +1744
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 -1848 to +1821
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:

keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
return keywords
return {"refnames": git_refnames, "full": git_full, "date": git_date}
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_keywords refactored with the following changes:

Comment on lines -92 to +104
print("unable to run %s" % dispcmd)
print(f"unable to run {dispcmd}")
print(e)
return None, None
else:
if verbose:
print("unable to find command, tried %s" % (commands,))
print(f"unable to find command, tried {commands}")
return None, None
stdout = p.communicate()[0].strip()
if sys.version_info[0] >= 3:
stdout = stdout.decode()
if p.returncode != 0:
if verbose:
print("unable to run %s (error)" % dispcmd)
print("stdout was %s" % stdout)
print(f"unable to run {dispcmd} (error)")
print(f"stdout was {stdout}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function run_command refactored with the following changes:

Comment on lines -119 to +118
for i in range(3):
for _ in range(3):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function versions_from_parentdir refactored with the following changes:

Comment on lines -150 to +157
f = open(versionfile_abs, "r")
for line in f.readlines():
if line.strip().startswith("git_refnames ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["refnames"] = mo.group(1)
if line.strip().startswith("git_full ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["full"] = mo.group(1)
if line.strip().startswith("git_date ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["date"] = mo.group(1)
f.close()
with open(versionfile_abs, "r") as f:
for line in f:
if line.strip().startswith("git_refnames ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["refnames"] = mo[1]
if line.strip().startswith("git_full ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["full"] = mo[1]
if line.strip().startswith("git_date ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["date"] = mo[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 git_get_keywords refactored with the following changes:

Comment on lines -189 to +186
refs = set([r.strip() for r in refnames.strip("()").split(",")])
refs = {r.strip() for r in refnames.strip("()").split(",")}
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
TAG = "tag: "
tags = set([r[len(TAG) :] for r in refs if r.startswith(TAG)])
tags = {r[len(TAG) :] for r in refs if r.startswith(TAG)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function git_versions_from_keywords refactored with the following changes:

Comment on lines -419 to +401
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 -496 to +472
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 -527 to +503
for i in cfg.versionfile_source.split("/"):
for _ in cfg.versionfile_source.split("/"):
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:

@@ -60,7 +60,6 @@ def _infer_from_model(self, context: str, question: str) -> Dict:
Infer the answer from the model. One question at a time.
"""

ret_val = dict()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TransformerQnAModel._infer_from_model refactored with the following changes:

@@ -1,3 +1,2 @@
def test_one_plus_one_is_two():
"Check that one and one are indeed two."
assert 1 + 1 == 2
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_one_plus_one_is_two 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