-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored xin branch #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
base: xin
Are you sure you want to change the base?
Conversation
| for prefix in ['.', 'appveyor.yml', 'docs/', 'misc/']: | ||
| if line.startswith(prefix): | ||
| return True | ||
| return False | ||
| return any( | ||
| line.startswith(prefix) | ||
| for prefix in ['.', 'appveyor.yml', 'docs/', 'misc/'] | ||
| ) |
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 sdist_files_from_git.get_file_list.exclude refactored with the following changes:
- Use any() instead of for loop (
use-any)
| if is_ssh: | ||
| return 0 | ||
| elif valid: | ||
| if is_ssh or valid: |
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 _certificate_cb refactored with the following changes:
- Merge duplicate blocks in conditional (
merge-duplicate-blocks) - Remove redundant conditional (
remove-redundant-if)
|
|
||
| # These are special error codes, they should never reach here | ||
| test = err != C.GIT_EUSER and err != C.GIT_PASSTHROUGH | ||
| test = err not in [C.GIT_EUSER, C.GIT_PASSTHROUGH] |
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 check_error refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
| repo = repo or self._repo | ||
|
|
||
| if repo: | ||
| if repo := repo or self._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 Index.write_tree refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
| else: | ||
| loid = None | ||
|
|
||
| loid = Oid(raw=bytes(ffi.buffer(refs[0][i].loid.id)[:])) if local else None |
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 Remote.ls_remotes refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| diff = commit_a.tree.diff_to_tree(commit_b.tree) | ||
| assert diff.patch == PATCH | ||
| assert len(diff) == len([patch for patch in diff]) | ||
| assert len(diff) == len(list(diff)) |
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_diff_patch refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension)
| # Compare SHAs, not IndexEntry object identity | ||
| entries = [index[x].hex for x in range(n)] | ||
| assert list(x.hex for x in index) == entries | ||
| assert [x.hex for x in index] == entries |
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_iter refactored with the following changes:
- Replace list(), dict() or set() with comprehension (
collection-builtin-to-comprehension)
| assert commit_a is not commit_b | ||
| assert commit_a == commit_b | ||
| assert not(commit_a != commit_b) | ||
| assert commit_a == commit_b |
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_equality refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan)
| s = set() | ||
| s.add(commit_a) | ||
| s.add(commit_b) | ||
| s = {commit_a, commit_b} | ||
| assert len(s) == 1 | ||
| assert commit_a in s | ||
| assert commit_b in s | ||
|
|
||
| d = {} | ||
| d[commit_a] = True | ||
| d = {commit_a: True} |
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_hashing refactored with the following changes:
- Merge add into set declaration (
merge-set-add) - Merge dictionary assignment with declaration (
merge-dict-assign)
| msg = msg+" short_id="+short_id | ||
| already = seen.get(short_id) | ||
| if already: | ||
| msg = f'{msg} short_id={short_id}' | ||
| if already := seen.get(short_id): |
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_short_id.test_obj refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation) - Use named expression to simplify assignment and conditional (
use-named-expression)
Branch
xinrefactored 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
xinbranch, then run:Help us improve this pull request!