-
Notifications
You must be signed in to change notification settings - Fork 1
Sourcery refactored master branch #17
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,9 +52,7 @@ def is_valid_year_range(s): | |
| _ = int(e) | ||
| except ValueError: | ||
| return False | ||
| if int(s[1]) < int(s[0]): | ||
| return False | ||
| return True | ||
| return int(s[1]) >= int(s[0]) | ||
|
|
||
| if is_valid_year_range(s): | ||
| setattr(namespace, self.dest, range(int(s[0]), int(s[-1]) + 1)) | ||
|
|
@@ -82,17 +80,16 @@ class CustomFormatter( | |
| ): | ||
| def _get_help_string(self, action): | ||
| help = action.help | ||
| 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)" | ||
|
Comment on lines
-85
to
+92
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function _get_help_string refactored with the following changes:
|
||
| return help | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,6 @@ def _copy_default_config(): | |
|
|
||
| def _find_config() -> Path: | ||
| """ look for cfgFile in the default locations """ | ||
| cfgFile = None | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function _find_config refactored with the following changes:
|
||
| env_var = os.environ.get("LDNDC2NC_CONF", "__NOTSET__") | ||
|
|
||
| locations = [ | ||
|
|
@@ -42,7 +41,7 @@ def _find_config() -> Path: | |
| if loc.is_file(): | ||
| return loc | ||
|
|
||
| return cfgFile | ||
| return None | ||
|
|
||
|
|
||
| def _parse_config(cfgFile): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,7 +147,7 @@ def _select_files(inpath, ldndc_file_type, limiter=""): | |
|
|
||
| infiles.sort() | ||
|
|
||
| if len(infiles) == 0: | ||
| if not infiles: | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function _select_files refactored with the following changes:
|
||
| msg = "No LandscapeDNDC input files of type <%s>\n" % ldndc_file_type | ||
| msg += "Input dir: %s\n" % inpath | ||
| if limiter != "": | ||
|
|
@@ -234,8 +234,8 @@ def read_ldndc_txt(inpath, varData, years, limiter=""): | |
| dfs.append(df) | ||
|
|
||
| # we don't have any dataframes, return | ||
| # 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: | ||
|
Comment on lines
-237
to
+238
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function read_ldndc_txt refactored with the following changes:
|
||
| log.warn("No data.frame filetype %s!" % ldndc_file_type) | ||
| continue | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
|
|
||
|
|
||
| def identical(elements: List) -> bool: | ||
| return all([e == elements[0] for e in elements]) | ||
| return all(e == elements[0] for e in elements) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function identical refactored with the following changes:
|
||
|
|
||
|
|
||
| def valid_brackets(s: str) -> bool: | ||
|
|
@@ -19,15 +19,13 @@ def valid_brackets(s: str) -> bool: | |
| cnt += 1 | ||
| if cnt > 1: | ||
| return False | ||
| 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 | ||
|
Comment on lines
-22
to
+28
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function valid_brackets refactored with the following changes:
|
||
|
|
||
|
|
||
| def variables_compatible(s: str, src: List[str]) -> bool: | ||
|
|
||
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 RangeAction.__call__.is_valid_year_range refactored with the following changes: