Conversation
| self.attrs = attrs.copy() | ||
| else: | ||
| self.attrs = {} | ||
| self.attrs = attrs.copy() if attrs is not None else {} |
There was a problem hiding this comment.
Function FileBrowseWidget.__init__ refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| if self.directory: | ||
| if callable(self.directory): | ||
| if directory: | ||
| if callable(directory): |
There was a problem hiding this comment.
Function FileBrowseWidget.render refactored with the following changes:
- Use previously assigned local variable (
use-assigned-variable)
| if self.extensions and not file_extension in self.extensions: | ||
| if self.extensions and file_extension not in self.extensions: |
There was a problem hiding this comment.
Function FileBrowseFormField.clean refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan)
| url = "http://" | ||
| else: | ||
| url = "/" | ||
| url = "http://" if args[0].startswith("http://") else "/" |
There was a problem hiding this comment.
Function url_join refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| if len(normalized) > 1: | ||
| value = '.'.join(normalized) | ||
| else: | ||
| value = normalized[0] | ||
|
|
||
| value = '.'.join(normalized) if len(normalized) > 1 else normalized[0] |
There was a problem hiding this comment.
Function convert_filename refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| for k, v in EXTENSIONS.items(): | ||
| counter[k] = 0 | ||
|
|
||
| counter = {k: 0 for k, v in EXTENSIONS.items()} |
There was a problem hiding this comment.
Function browse refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if) - Convert for loop into dictionary comprehension (
dict-comprehension)
| if k != "folder" and default_storage.exists( | ||
| os.path.join(get_directory(), folder, v) | ||
| ): | ||
| fileArray[k] = v |
There was a problem hiding this comment.
Function _check_file refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs)
| ON_EACH_SIDE = 3 | ||
| ON_ENDS = 2 | ||
|
|
There was a problem hiding this comment.
Function pagination refactored with the following changes:
- Move assignments closer to their usage (
move-assign) - Replace range(0, x) with range(x) (
remove-zero-from-range)
| if filetype and format and filetype in SELECT_FORMATS[format]: | ||
| selectable = True | ||
| elif filetype and format and filetype not in SELECT_FORMATS[format]: | ||
| elif filetype and format: |
There was a problem hiding this comment.
Function SelectableNode.render refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if)
Sourcery Code Quality Report (beta)✅ Merging this PR will increase code quality in the affected files by 0.02 out of 10.
Here are some functions in these files that still need a tune-up:
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! |
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: