-
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 master branch #1
base: master
Are you sure you want to change the base?
Conversation
if new_param is None: | ||
# if we still cannot find any new parameters, break | ||
break | ||
if new_param is None: | ||
# if we still cannot find any new parameters, break | ||
break |
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 extract_params
refactored with the following changes:
- Hoist conditional out of nested conditional (
hoist-if-from-if
)
<kbd>{name}({", ".join([param for param in funcs[name]['parameters']])})</kbd><br><br> | ||
<kbd>{name}({", ".join(list(funcs[name]['parameters']))})</kbd><br><br> | ||
<p> | ||
{funcs[name]['description']} | ||
</p> | ||
""" | ||
|
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 functions_html
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
) - Replace f-string with no interpolated values with string [×2] (
remove-redundant-fstring
)
# !!! TODO make the navbar code here | ||
navbar = "" | ||
|
||
# now save to templates within the docs directory | ||
output(navbar, 'navbar.js', os.path.join(docs_dir, 'templates')) |
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 build_navbar
refactored with the following changes:
- Remove unreachable code (
remove-unreachable-code
)
This removes the following comments ( why? ):
# now save to templates within the docs directory
# !!! TODO make the navbar code here
if submodule != "": | ||
fullpath = [module, submodule] | ||
else: | ||
fullpath = [module] | ||
|
||
fullpath = [module, submodule] if submodule != "" else [module] |
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 build_page
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
if not any([ext in filename for ext in file_types]): | ||
if all(ext not in filename for ext in file_types): |
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 output
refactored with the following changes:
- Invert any/all to simplify comparisons (
invert-any-all
) - Replace unneeded comprehension with generator (
comprehension-to-generator
) - Swap if/else to remove empty if body (
remove-pass-body
)
|
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.
Found the following improvement in Function bootstrap_download
:
if not any([os.path.exists(loc) for loc in bootstraps]): | ||
if not any(os.path.exists(loc) for loc in bootstraps): | ||
# if any do not exist, we download all | ||
print("Not all required Bootstrap files found. " | ||
"They will be downloaded to " | ||
f"'{os.path.join(docs_dir, 'templates')}'.") | ||
# download bootstrap files | ||
bootstrap_download(docs_dir) | ||
|
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 DocsBuilder.__init__
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
if new_class is None: | ||
# if no classes anywhere, break the loop | ||
break | ||
if new_class is None: | ||
# if no classes anywhere, break the loop | ||
break |
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 DocsBuilder.extract
refactored with the following changes:
- Hoist conditional out of nested conditional (
hoist-if-from-if
)
# we may end up with multiple pages, so initialise Dictionary | ||
pages = {} | ||
# filename version of module | ||
filename = self.module.lower().replace(" ", "_") | ||
# build top-level page | ||
pages[filename] = \ | ||
build_page(self.module, self.devs, self.desc, self.classes, | ||
self.funcs) | ||
pages = { | ||
filename: build_page( | ||
self.module, self.devs, self.desc, self.classes, self.funcs | ||
) | ||
} | ||
|
||
# iterate through classes (if any) and build page for each | ||
if len(self.classes) > 0: | ||
for c in self.classes: | ||
print(f"{filename}.{c}") | ||
print(c) | ||
pages[f"{filename}.{c}"] = \ | ||
build_page(self.module, self.devs, | ||
build_page(self.module, self.devs, | ||
self.classes[c]['description'], classes="", | ||
funcs=self.classes[c]['funcs'], submodule=c) | ||
|
||
# finally save all to file | ||
for page in pages: | ||
output(pages[page], page, path=path) | ||
for page, value in pages.items(): | ||
output(value, page, path=path) |
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 DocsBuilder.build
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Use items() to directly unpack dictionary values (
use-dict-items
) - Merge dictionary assignment with declaration (
merge-dict-assign
)
This removes the following comments ( why? ):
# we may end up with multiple pages, so initialise Dictionary
# build top-level page
Branch
master
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
master
branch, then run:Help us improve this pull request!