Conversation
|
|
||
| pass_context = click.make_pass_decorator(Context, ensure = True) | ||
| cmd_folder = os.path.join(BASE_DIR + '/cli', 'commands') | ||
| cmd_folder = os.path.join(f'{BASE_DIR}/cli', 'commands') |
There was a problem hiding this comment.
Lines 28-28 refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| rv = [] | ||
| for filename in os.listdir(cmd_folder): | ||
| if filename.endswith('.py') and \ | ||
| filename.startswith('cmd_'): | ||
| rv.append(filename[4:-3]) | ||
| rv = [ | ||
| filename[4:-3] | ||
| for filename in os.listdir(cmd_folder) | ||
| if filename.endswith('.py') and filename.startswith('cmd_') | ||
| ] |
There was a problem hiding this comment.
Function CLI.list_commands refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension)
| mod = __import__('cli.commands.cmd_' + name, locals = None, globals = None, fromlist = ['cli']) | ||
| mod = __import__( | ||
| f'cli.commands.cmd_{name}', | ||
| locals=None, | ||
| globals=None, | ||
| fromlist=['cli'], | ||
| ) |
There was a problem hiding this comment.
Function CLI.get_command refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| f" pass") | ||
|
|
||
| with open(f'api/__init__.py', 'a+') as f: | ||
| with open('api/__init__.py', 'a+') as f: |
There was a problem hiding this comment.
Function make_api refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring)
| ''') | ||
|
|
||
| with open(f'models/__init__.py', 'a+') as f: | ||
| with open('models/__init__.py', 'a+') as f: |
There was a problem hiding this comment.
Function make_model refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring)
| handler = RotatingFileHandler(LOG_DIR + '/app.log', maxBytes = 1000000, backupCount = 5) | ||
| handler = RotatingFileHandler( | ||
| f'{LOG_DIR}/app.log', maxBytes=1000000, backupCount=5 | ||
| ) |
There was a problem hiding this comment.
Lines 64-64 refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| if mime_type in _mime_types[ext]: | ||
| exts.append(ext) | ||
| return exts | ||
| return [ext for ext in _mime_types if mime_type in _mime_types[ext]] |
There was a problem hiding this comment.
Function get_extensions refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| if equal is NotImplemented: | ||
| return NotImplemented | ||
| return not equal | ||
| return NotImplemented if equal is NotImplemented else not equal |
There was a problem hiding this comment.
Function UserMixin.__ne__ refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp)
|
|
||
| def __repr__(self): | ||
| return '<User {}>'.format(self.username) | ||
| return f'<User {self.username}>' |
There was a problem hiding this comment.
Function User.__repr__ refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| def lookup(cls, username): | ||
| result = cls.query().where('username', username).first_or_fail() | ||
| if result: | ||
| if result := cls.query().where('username', username).first_or_fail(): |
There was a problem hiding this comment.
Function User.lookup refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
Branch
masterrefactored 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
masterbranch, then run:Help us improve this pull request!