Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jun 4, 2020

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:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

@sourcery-ai sourcery-ai bot force-pushed the sourcery/master branch from 1bfee28 to 5d0e89c Compare June 4, 2020 12:45
if int(s[1]) < int(s[0]):
return False
return True
return int(s[1]) >= int(s[0])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RangeAction.__call__.is_valid_year_range refactored with the following changes:

  • Simplify conditional into return statement

Comment on lines -85 to +92
if "%(default)" not in action.help:
if action.default is not argparse.SUPPRESS:
defaulting_nargs = [argparse.OPTIONAL, argparse.ZERO_OR_MORE]
if action.option_strings or action.nargs in defaulting_nargs:
if type(action.default) == list:
help += " (default: %d-%d)" % (
action.default[0],
action.default[-1],
)
else:
help += " (default: %(default)s)"
if "%(default)" not in help and action.default is not argparse.SUPPRESS:
defaulting_nargs = [argparse.OPTIONAL, argparse.ZERO_OR_MORE]
if action.option_strings or action.nargs in defaulting_nargs:
if type(action.default) == list:
help += " (default: %d-%d)" % (
action.default[0],
action.default[-1],
)
else:
help += " (default: %(default)s)"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _get_help_string refactored with the following changes:

  • Merge nested if conditions
  • Swap positions of nested conditionals
  • Hoist repeated code outside conditional statement
  • Use previously assigned local variable


def _find_config() -> Path:
""" look for cfgFile in the default locations """
cfgFile = None
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _find_config refactored with the following changes:

  • Inline variable that is only used once

infiles.sort()

if len(infiles) == 0:
if not infiles:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _select_files refactored with the following changes:

  • Simplify sequence comparison

Comment on lines -237 to +238
# TODO: the control flow here should be more obvious
if len(dfs) == 0:
# TODO: the control flow here should be more obvious
if not dfs:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function read_ldndc_txt refactored with the following changes:

  • Simplify sequence comparison


def identical(elements: List) -> bool:
return all([e == elements[0] for e in elements])
return all(e == elements[0] for e in elements)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function identical refactored with the following changes:

  • Replace unneeded comprehension with generator

Comment on lines -22 to +28
if l == "]":
elif l == "]":
cnt -= 1
if cnt == 0:
cnt_closed += 1
elif cnt < 0:
return False
if cnt_closed > 1:
return False
return True
return cnt_closed <= 1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function valid_brackets refactored with the following changes:

  • Simplify conditional into switch-like form
  • Simplify conditional into return statement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant