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 #3

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 Nov 30, 2023

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 strickvl November 30, 2023 08:55
Comment on lines -13 to +14
for o in expected: assert o in cfg, "missing expected setting: {}".format(o)
for o in expected:
assert o in cfg, f"missing expected setting: {o}"
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-63 refactored with the following changes:

if partial_url[0] == "/":
return base_url + partial_url
else:
return partial_url
return base_url + partial_url if partial_url[0] == "/" else partial_url
Copy link
Author

Choose a reason for hiding this comment

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

Function add_scheme_and_domain refactored with the following changes:

Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

PR Type: Refactoring

Summary of PR: This PR introduces refactoring changes made by Sourcery, an automated code review and refactoring tool, to the main branch of the repository. The changes include the use of f-strings for string formatting, simplification of conditional statements, and restructuring of list and dictionary comprehensions.

General PR suggestions

  • Ensure that the use of f-strings in exception messages does not lead to unnecessary expression evaluations. Traditional string formatting with lazy evaluation might be more appropriate in some cases.
  • Be cautious with the use of f-strings in regular expressions, especially when dealing with strings that may contain regex metacharacters. Proper escaping is necessary to avoid potential bugs.
  • Consider the readability of one-liner conditional statements. In some cases, the original multi-line if-else blocks may be more readable and maintainable.
  • When using methods like cfg.get to provide default values, ensure that the defaults are appropriate for the application's requirements and won't lead to unexpected behavior.
  • Review the changes for consistency and adherence to the project's coding standards, as automated refactoring tools may not always align with project-specific guidelines.

Your trial expires on December 14, 2023. Please email tim@sourcery.ai to continue using Sourcery ✨

@@ -10,7 +10,8 @@

cfg_keys = 'version description keywords author author_email'.split()
expected = cfg_keys + "lib_name user branch license status min_python audience language".split()
for o in expected: assert o in cfg, "missing expected setting: {}".format(o)
for o in expected:
assert o in cfg, f"missing expected setting: {o}"
Copy link
Author

Choose a reason for hiding this comment

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

suggestion (llm): Using f-strings for exceptions is not recommended as it can lead to the evaluation of expressions that might not be needed if the assertion does not fail. Consider using the traditional formatting which evaluates lazily.

Suggested change
assert o in cfg, f"missing expected setting: {o}"
assert o in cfg, "missing expected setting: %s" % o

long_description = re.sub(r'src=\"(.*)\.'+ext+'\"', 'src=\"https://raw.githubusercontent.com/{}/{}'.format(cfg['user'],cfg['lib_name'])+'/'+cfg['branch']+'/\\1.'+ext+'\"', long_description)
long_description = re.sub(
r'!\[' + ext + '\]\((.*)\)',
f'![{ext}]('
Copy link
Author

Choose a reason for hiding this comment

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

issue (llm): The refactored regular expression replacement using f-strings may introduce a bug if 'ext' contains special regex characters. Ensure that 'ext' is properly escaped if it's expected to contain regex metacharacters.

return base_url + partial_url
else:
return partial_url
return base_url + partial_url if partial_url[0] == "/" else partial_url
Copy link
Author

Choose a reason for hiding this comment

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

suggestion (llm): The refactored one-liner for URL concatenation is less readable than the original if-else block. Consider reverting to the original block or using a more readable approach.

Suggested change
return base_url + partial_url if partial_url[0] == "/" else partial_url
- return base_url + partial_url if partial_url[0] == "/" else partial_url

long_description=long_description,
long_description_content_type='text/markdown',
zip_safe=False,
entry_points={'console_scripts': cfg.get('console_scripts', '').split()},
Copy link
Author

Choose a reason for hiding this comment

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

thought (llm): The change to use 'cfg.get' for 'console_scripts' is good for handling missing keys, but ensure that the default empty string is an appropriate fallback for your application's needs.

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.

None yet

0 participants