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 refactored main branch #1

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

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jan 12, 2024

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from dan5e3s6ares January 12, 2024 22:52
print('pytest arguments: {}'.format(args))
print(f'pytest arguments: {args}')
Copy link
Author

Choose a reason for hiding this comment

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

Lines 14-14 refactored with the following changes:

Comment on lines -321 to +323
print("Warning: build in %s is using versioneer.py from %s"
% (os.path.dirname(me), versioneer_py))
print(
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 -396 to +408
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().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 -949 to +960
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.group(1)
if line.strip().startswith("git_full ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["full"] = mo.group(1)
if line.strip().startswith("git_date ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["date"] = mo.group(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 -992 to +993
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 +1497 to +1498


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? ):

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

Comment on lines -1745 to +1747
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 -1818 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 -89 to +99
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().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 -114 to +125
for i in range(3):
for _ in range(3):
dirname = os.path.basename(root)
if dirname.startswith(parentdir_prefix):
return {"version": dirname[len(parentdir_prefix):],
"full-revisionid": None,
"dirty": False, "error": None, "date": None}
else:
rootdirs.append(root)
root = os.path.dirname(root) # up a level
rootdirs.append(root)
root = os.path.dirname(root) # up a level

if verbose:
print("Tried directories %s but none started with prefix %s" %
(str(rootdirs), parentdir_prefix))
print(
f"Tried directories {rootdirs} but none started with prefix {parentdir_prefix}"
)
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 -139 to +148
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.group(1)
if line.strip().startswith("git_full ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["full"] = mo.group(1)
if line.strip().startswith("git_date ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["date"] = mo.group(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 -182 to +181
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 -226 to +243
GITS = ["git"]
if sys.platform == "win32":
GITS = ["git.cmd", "git.exe"]

GITS = ["git.cmd", "git.exe"] if sys.platform == "win32" else ["git"]
out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root,
hide_stderr=True)
if rc != 0:
if verbose:
print("Directory %s not under git control" % root)
print(f"Directory {root} not under git control")
raise NotThisMethod("'git rev-parse --git-dir' returned error")

# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
# if there isn't one, this yields HEX[-dirty] (no NUM)
describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty",
"--always", "--long",
"--match", "%s*" % tag_prefix],
cwd=root)
describe_out, rc = run_command(
GITS,
[
"describe",
"--tags",
"--dirty",
"--always",
"--long",
"--match",
f"{tag_prefix}*",
],
cwd=root,
)
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_pieces_from_vcs refactored with the following changes:

This removes the following comments ( why? ):

# maybe improved later

Comment on lines -315 to +309
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 -652 to +651
status = webbrowser.open(url, location)
return status
return webbrowser.open(url, location)
Copy link
Author

Choose a reason for hiding this comment

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

Function DesktopBot.browse refactored with the following changes:

Comment on lines -977 to +975
for i in range(presses):
for _ in range(presses):
Copy link
Author

Choose a reason for hiding this comment

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

Function DesktopBot.tab refactored with the following changes:

Comment on lines -991 to +989
for i in range(presses):
for _ in range(presses):
Copy link
Author

Choose a reason for hiding this comment

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

Function DesktopBot.enter refactored with the following changes:

Comment on lines -1144 to +1142
key_value = keys_map.get(key, None)
if key_value:
if key_value := keys_map.get(key, None):
Copy link
Author

Choose a reason for hiding this comment

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

Function DesktopBot.type_keys_with_interval refactored with the following changes:

Comment on lines -1645 to +1642
dialog = find_window(self.app, waiting_time, **selectors)
return dialog
return find_window(self.app, waiting_time, **selectors)
Copy link
Author

Choose a reason for hiding this comment

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

Function DesktopBot.find_app_window refactored with the following changes:

Comment on lines -1666 to +1662
element = find_element(self.app, from_parent_window, waiting_time, **selectors)
return element
return find_element(self.app, from_parent_window, waiting_time, **selectors)
Copy link
Author

Choose a reason for hiding this comment

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

Function DesktopBot.find_app_element refactored with the following changes:

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

Choose a reason for hiding this comment

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

Function _mouse_click refactored with the following changes:

app = Application(backend=backend).connect(**connection_selectors)
return app
return Application(backend=backend).connect(**connection_selectors)
Copy link
Author

Choose a reason for hiding this comment

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

Function connect refactored with the following changes:

Comment on lines -43 to +44
if USE_FIND_MULTIPLE:
# Using Find Parallel
for index, row in df.iterrows():
for index, row in df.iterrows():
if USE_FIND_MULTIPLE:
Copy link
Author

Choose a reason for hiding this comment

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

Function Bot.action refactored with the following changes:

This removes the following comments ( why? ):

# Using Find Serial Mode
# Using Find Parallel

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.

0 participants