-
Notifications
You must be signed in to change notification settings - Fork 0
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 develop branch #1
base: develop
Are you sure you want to change the base?
Conversation
if test == 1: | ||
if test == 1: | ||
return 28 | ||
elif test == 2: | ||
return 28 | ||
return 28 | ||
elif test == 2: | ||
if test in {1, 2}: | ||
return 28 |
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 Message.__init__
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
) - Remove redundant conditional (
remove-redundant-if
) - Remove unreachable code (
remove-unreachable-code
) - Use set when checking membership of a collection of literals (
collection-into-set
)
return '%s:%s: %s' % (self.filename, self.lineno, self.message % self.message_args) | ||
return f'{self.filename}:{self.lineno}: {self.message % self.message_args}' |
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 Message.__str__
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
return set(x for x in val if x) | ||
return {x for x in val if x} |
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 split_csp_str
refactored with the following changes:
- Replace list(), dict() or set() with comprehension (
collection-builtin-to-comprehension
)
return dict((v, n) for n, v in enumerate(types, 1)) | ||
return {v: n for n, v in enumerate(types, 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 prepare_sorter
refactored with the following changes:
- Replace list(), dict() or set() with comprehension (
collection-builtin-to-comprehension
)
"--version", action="version", version="%(prog)s " + __version__ | ||
"--version", action="version", version=f"%(prog)s {__version__}" |
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 setup_parser
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Simplify generator expression (
simplify-generator
)
text=str("Found commented out code"), | ||
text="Found commented out code", |
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 Linter.run_check
refactored with the following changes:
- Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
options = ctx.options | ||
if options: | ||
if options := ctx.options: |
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 Linter.run_check
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
options = ctx.options | ||
if options: | ||
if options := ctx.options: |
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 Linter.run_check
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
def run_check(self, ctx: RunContext): # noqa # noqa | ||
def run_check(self, ctx: RunContext): # noqa # noqa | ||
"""Check code with Radon.""" | ||
params = ctx.get_params("radon") | ||
options = ctx.options | ||
if options: | ||
if options := ctx.options: |
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 Linter.run_check
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
def run_check(self, ctx: RunContext): # noqa | ||
def run_check(self, ctx: RunContext): # noqa | ||
"""Check code with vulture.""" | ||
params = ctx.get_params("vulture") | ||
options = ctx.options | ||
if options: | ||
if options := ctx.options: |
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 Linter.run_check
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.05%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
assert set(options.linters) == set(["pydocstyle", "pycodestyle"]) | ||
assert set(options.linters) == {"pydocstyle", "pycodestyle"} | ||
assert options.ignore == {"E"} | ||
|
||
options = parse_options("-o dummy dummy.py".split()) | ||
assert set(options.linters) == set(["pycodestyle", "mccabe", "pyflakes"]) | ||
assert set(options.linters) == {"pycodestyle", "mccabe", "pyflakes"} |
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_config
refactored with the following changes:
- Unwrap a constant iterable constructor [×2] (
unwrap-iterable-construction
)
Branch
develop
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
develop
branch, then run:Help us improve this pull request!