Sourcery Starbot ⭐ refactored amitkot/obsidian-html#1
Conversation
| paths = {} | ||
| this_file_path = os.path.realpath(__file__) # (..)/obsidian-html/ci/tests/__filename__ | ||
| paths['ci_tests'] = Path(this_file_path).parent # (..)/obsidian-html/ci/tests/ | ||
| paths = {'ci_tests': Path(this_file_path).parent} |
There was a problem hiding this comment.
Function get_paths refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block) - Merge dictionary assignment with declaration (
merge-dict-assign)
This removes the following comments ( why? ):
# (..)/obsidian-html/ci/tests/
| if output_dict: | ||
| return {'soup': soup, 'url': url} | ||
| else: | ||
| return soup | ||
| return {'soup': soup, 'url': url} if output_dict else soup |
There was a problem hiding this comment.
Function html_get refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| # Merge the two | ||
| config = MergeDictRecurse(sys_config, default_config) | ||
|
|
||
| return config | ||
| return MergeDictRecurse(sys_config, default_config) |
There was a problem hiding this comment.
Function get_default_config refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
This removes the following comments ( why? ):
# Merge the two
|
|
There was a problem hiding this comment.
Function TestDefaultMode.test_C_rss refactored with the following changes:
- Simplify sequence length comparison (
simplify-len-comparison)
| for i, v in enumerate(sys.argv): | ||
| if v == '-r': | ||
| run_setup = True | ||
| for v in sys.argv: | ||
| if v == '-c': | ||
| run_cleanup = True | ||
| if v == 'v': | ||
| elif v == '-r': | ||
| run_setup = True | ||
| elif v == 'v': | ||
| verbose = True | ||
|
|
||
| # get paths | ||
| paths = get_paths() | ||
|
|
There was a problem hiding this comment.
Lines 456-466 refactored with the following changes:
- Remove unnecessary calls to
enumeratewhen the index is not used (remove-unused-enumerate) - Simplify conditional into switch-like form (
switch)
| header = soup.body.find('h'+str(header_level)) | ||
| header = soup.body.find(f'h{str(header_level)}') |
There was a problem hiding this comment.
Function selector_first_header refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| for i in range(arg[1]): | ||
| for _ in range(arg[1]): | ||
| el = el.parent | ||
| value += el.name | ||
|
|
||
| # Get filename minus suffix | ||
|
|
There was a problem hiding this comment.
Function selector_path refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
This removes the following comments ( why? ):
# Get filename minus suffix
| md.dst_path = md.dst_path.parent.joinpath('index__2.md') | ||
| md.rel_dst_path = md.dst_path.relative_to(md.dst_folder_path) | ||
|
|
There was a problem hiding this comment.
Function ConvertMarkdownPageToHtmlPage refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| header = '' | ||
| if len(parts) > 1: | ||
| header = parts[1] | ||
|
|
||
| header = parts[1] if len(parts) > 1 else '' | ||
| if filename[-3:] != '.md': | ||
| filename += '.md' | ||
|
|
There was a problem hiding this comment.
Function GetObsidianFilePath refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp) - Move setting of default value for variable into
elsebranch (introduce-default-else)
|
|
||
| # other cases -> copy over | ||
| if isinstance(update_dict[k], list): | ||
| base_dict[k] = v.copy() | ||
| else: | ||
| base_dict[k] = v | ||
|
|
||
| # other cases -> copy over | ||
| base_dict[k] = v.copy() if isinstance(update_dict[k], list) else v |
There was a problem hiding this comment.
Function MergeDictRecurse refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: