Sourcery refactored main branch#27
Conversation
|
Thank you for contributing to Python Discord! Please check out the following documents:
|
| if inspect.isclass(member): | ||
| if issubclass(member, Route) and member != Route: | ||
| member.check_parameters() | ||
|
|
||
| levels = str(file.parent).split("/")[2:] | ||
|
|
||
| current_level = None | ||
| for level in levels: | ||
| if current_level is None: | ||
| current_level = route_dict[f"/{level}"] | ||
| else: | ||
| current_level = current_level[f"/{level}"] | ||
|
|
||
| if current_level is not None: | ||
| current_level[member.path] = member | ||
| if ( | ||
| inspect.isclass(member) | ||
| and issubclass(member, Route) | ||
| and member != Route | ||
| ): | ||
| member.check_parameters() | ||
|
|
||
| levels = str(file.parent).split("/")[2:] | ||
|
|
||
| current_level = None | ||
| for level in levels: | ||
| if current_level is None: | ||
| current_level = route_dict[f"/{level}"] | ||
| else: | ||
| route_dict[member.path] = member | ||
| current_level = current_level[f"/{level}"] | ||
|
|
||
| route_map = construct_route_map_from_dict(route_dict.to_dict()) | ||
| if current_level is not None: | ||
| current_level[member.path] = member | ||
| else: | ||
| route_dict[member.path] = member | ||
|
|
||
| return route_map | ||
| return construct_route_map_from_dict(route_dict.to_dict()) |
There was a problem hiding this comment.
Function create_route_map refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable) - Merge nested if conditions (
merge-nested-ifs)
| allowed_values = list(v.value for v in FormFeatures.__members__.values()) | ||
| if not all(v in allowed_values for v in value): | ||
| allowed_values = [v.value for v in FormFeatures.__members__.values()] | ||
| if any(v not in allowed_values for v in value): |
There was a problem hiding this comment.
Function Form.validate_features refactored with the following changes:
- Invert any/all to simplify comparisons (
invert-any-all) - Replace list(), dict() or set() with comprehension (
collection-builtin-to-comprehension)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 3.26%.
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! Let us know what you think of it by mentioning @sourcery-ai in a comment. |
Branch
mainrefactored 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
mainbranch, then run: