-
Notifications
You must be signed in to change notification settings - Fork 11
Sourcery Starbot ⭐ refactored michaeljoseph/changes #282
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: main
Are you sure you want to change the base?
Conversation
labels = set( | ||
[ | ||
label_name | ||
for pull_request in pull_requests | ||
for label_name in pull_request.label_names | ||
] | ||
) | ||
labels = { | ||
label_name | ||
for pull_request in pull_requests | ||
for label_name in pull_request.label_names | ||
} | ||
|
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 release_from_pull_requests
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Replace unneeded comprehension with generator (
comprehension-to-generator
) - Replace list(), dict() or set() with comprehension (
collection-builtin-to-comprehension
) - Replace identity comprehension with call to collection constructor (
identity-comprehension
)
with open('%s/__init__.py' % module_name) as input_file: | ||
with open(f'{module_name}/__init__.py') as input_file: |
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 extract_attribute
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
init_file = '%s/__init__.py' % module_name | ||
init_file = f'{module_name}/__init__.py' |
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_attribute
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
init_file = '%s/__init__.py' % module_name | ||
init_file = f'{module_name}/__init__.py' | ||
return any( | ||
[attribute_name in init_line for init_line in open(init_file).readlines()] | ||
attribute_name in init_line | ||
for init_line in open(init_file).readlines() |
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 has_attribute
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
) - Replace unneeded comprehension with generator (
comprehension-to-generator
)
# http://stackoverflow.com/a/468378/5549 | ||
sha1_re = re.match(r'^[0-9a-f]{5,40}\b', line) | ||
if sha1_re: | ||
if sha1_re := re.match(r'^[0-9a-f]{5,40}\b', line): | ||
sha1 = sha1_re.group() | ||
|
||
new_line = line.replace(sha1, '[%s](%s/commit/%s)' % (sha1, repo_url, sha1)) | ||
new_line = line.replace(sha1, f'[{sha1}]({repo_url}/commit/{sha1})') |
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_sha_with_commit_link
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
This removes the following comments ( why? ):
# http://stackoverflow.com/a/468378/5549
install_cmd = '%s/bin/pip install %s' % (tmp_dir, context.module_name) | ||
install_cmd = f'{tmp_dir}/bin/pip install {context.module_name}' | ||
|
||
package_index = 'pypi' | ||
if context.pypi: | ||
install_cmd += '-i %s' % context.pypi | ||
install_cmd += f'-i {context.pypi}' |
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 install_from_pypi
refactored with the following changes:
- Replace interpolated string formatting with f-string [×3] (
replace-interpolation-with-fstring
)
log.info('%s? %s' % (probe_name, probe_result)) | ||
log.info(f'{probe_name}? {probe_result}') |
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 report_and_raise
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
log.info('%s does not exist' % command) | ||
log.info(f'{command} does not exist') |
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 has_binary
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
return any([has_binary(tool) for tool in TOOLS]) | ||
return any(has_binary(tool) for tool in TOOLS) |
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 has_tools
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
return any([has_binary(runner) for runner in TEST_RUNNERS]) | ||
return any(has_binary(runner) for runner in TEST_RUNNERS) |
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 has_test_runner
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
any([exists('README{}'.format(ext)) for ext in README_EXTENSIONS]), | ||
any(exists(f'README{ext}') for ext in README_EXTENSIONS), |
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 has_readme
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
) - Replace call to format with f-string (
use-fstring-for-formatting
)
init_path = '{}/__init__.py'.format(python_module) | ||
init_path = f'{python_module}/__init__.py' |
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 has_metadata
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
('{}'.format(i), value) for i, value in enumerate(alternatives, 1) | ||
(f'{i}', value) for i, value in enumerate(alternatives, 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 choose_labels
refactored with the following changes:
- Replace call to format with f-string [×3] (
use-fstring-for-formatting
) - Simplify logical expression using De Morgan identities (
de-morgan
)
return {'Authorization': 'token {}'.format(self.auth_token)} | ||
return {'Authorization': f'token {self.auth_token}'} |
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 GitHub.headers
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
log.info('Dry run of %s, skipping' % command) | ||
log.info(f'Dry run of {command}, skipping') |
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 dry_run
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
info('Status [{}/{}]'.format(repository.owner, repository.repo)) | ||
info(f'Status [{repository.owner}/{repository.repo}]') | ||
|
||
info('Repository: ' + highlight('{}/{}'.format(repository.owner, repository.repo))) | ||
info(f"Repository: {highlight(f'{repository.owner}/{repository.repo}')}") |
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 status
refactored with the following changes:
- Replace call to format with f-string [×6] (
use-fstring-for-formatting
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
) + ((' ' + self.name) if self.name else '') | ||
) + (f' {self.name}' if self.name 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 Release.title
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
) + (('-' + self.name) if self.name else '') | ||
) + (f'-{self.name}' if self.name 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 Release.release_note_filename
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
while not version_file_path_answer == input_terminator: | ||
while version_file_path_answer != input_terminator: |
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 BumpVersion.load
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
'[bumpversion:file:{}]'.format(file_name) | ||
f'[bumpversion:file:{file_name}]' | ||
for file_name in self.version_files_to_replace | ||
] | ||
) | ||
|
||
|
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 BumpVersion.write_to_file
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
return git('config --get remote.{}.url'.format(self.REMOTE_NAME)) | ||
return git(f'config --get remote.{self.REMOTE_NAME}.url') |
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 GitRepository.remote_url
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
revision_range = ' {}..HEAD'.format(version) if version else '' | ||
revision_range = f' {version}..HEAD' if version else '' | ||
|
||
merge_commits = git( | ||
'log --oneline --merges --no-color{}'.format(revision_range) | ||
).split('\n') | ||
return merge_commits | ||
return git(f'log --oneline --merges --no-color{revision_range}').split('\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 GitRepository.merges_since
refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
return git('add {}'.format(' '.join(files_to_add))) | ||
return git(f"add {' '.join(files_to_add)}") |
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 GitRepository.add
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
return git_command['commit', '--message="{}"'.format(message)]() | ||
return git_command['commit', f'--message="{message}"']() |
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 GitRepository.commit
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
return git('checkout -- {}'.format(' '.join(file_paths))) | ||
return git(f"checkout -- {' '.join(file_paths)}") |
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 GitRepository.discard
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
assert result.output == 'changes {}\n'.format(changes.__version__) | ||
assert result.output == f'changes {changes.__version__}\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 test_version
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
'docs/releases/0.0.2-{}-Icarus.md'.format(date.today().isoformat()) | ||
f'docs/releases/0.0.2-{date.today().isoformat()}-Icarus.md' | ||
) | ||
|
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 test_publish
refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting
)
release_notes_path = Path( | ||
'docs/releases/0.0.2-{}.md'.format(date.today().isoformat()) | ||
) | ||
release_notes_path = Path(f'docs/releases/0.0.2-{date.today().isoformat()}.md') |
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 test_stage_draft
refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting
)
'docs/releases/0.0.2-{}-Icarus.md'.format(date.today().isoformat()) | ||
f'docs/releases/0.0.2-{date.today().isoformat()}-Icarus.md' | ||
) | ||
|
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 test_stage
refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting
)
'docs/releases/0.0.2-{}-Icarus.md'.format(date.today().isoformat()) | ||
f'docs/releases/0.0.2-{date.today().isoformat()}-Icarus.md' | ||
) | ||
|
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 test_stage_discard
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
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: