Conversation
| dataDict = {} | ||
| for i in range(len(encodedCols)): | ||
| dataDict[f"col{1 + i}"] = list(encodedCols[i]) | ||
| dataDict = { | ||
| f"col{1 + i}": list(encodedCols[i]) for i in range(len(encodedCols)) | ||
| } |
There was a problem hiding this comment.
Function PCA refactored with the following changes:
- Convert for loop into dictionary comprehension (
dict-comprehension)
| return p_value | ||
| # two sample t-test where _arg1 is numeric and _arg2 is a binary factor | ||
| elif len(set(_arg2)) == 2: | ||
| # each sample in _arg1 needs to have a corresponding classification | ||
| # in _arg2 | ||
| if not (len(_arg1) == len(_arg2)): | ||
| if len(_arg1) != len(_arg2): |
There was a problem hiding this comment.
Function ttest refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if) - Simplify logical expression using De Morgan identities (
de-morgan)
This removes the following comments ( why? ):
# arg1 is a sample and arg2 is a sample
# two sample t-test where _arg1 is numeric and _arg2 is a binary factor
| pkg_path = os.path.dirname(tabpy.__file__) | ||
| config_file_path = os.path.join(pkg_path, "tabpy_server", "common", "default.conf") | ||
| return config_file_path | ||
| return os.path.join(pkg_path, "tabpy_server", "common", "default.conf") |
There was a problem hiding this comment.
Function get_default_config_file_path refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| port = 9004 | ||
| if "TABPY_PORT" in tabpy_config: | ||
| port = tabpy_config["TABPY_PORT"] | ||
|
|
||
| port = tabpy_config["TABPY_PORT"] if "TABPY_PORT" in tabpy_config else 9004 |
There was a problem hiding this comment.
Function parse_config 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)
| msg = https_error + f"The certificate provided is not valid until {not_before}." | ||
| msg = f"{https_error}The certificate provided is not valid until {not_before}." | ||
| logger.critical(msg) | ||
| raise RuntimeError(msg) | ||
| if now > not_after: | ||
| msg = https_error + f"The certificate provided expired on {not_after}." | ||
| msg = f"{https_error}The certificate provided expired on {not_after}." |
There was a problem hiding this comment.
Function validate_cert refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| sub_path.append(str(version)) | ||
| full_path = root_path + "/".join(sub_path) | ||
| return full_path | ||
| return root_path + "/".join(sub_path) |
There was a problem hiding this comment.
Function get_query_object_path refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| endpoint_info["docstring"] = str( | ||
| bytes(docstring, "utf-8").decode("unicode_escape") | ||
| ) | ||
| endpoint_info["docstring"] = bytes(docstring, "utf-8").decode("unicode_escape") |
There was a problem hiding this comment.
Function TabPyState.get_endpoints refactored with the following changes:
- Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast)
| if dependencies or not isinstance(dependencies, list): | ||
| raise ValueError("dependencies must be a list.") | ||
|
|
||
| return dependencies | ||
| raise ValueError("dependencies must be a list.") |
There was a problem hiding this comment.
Function TabPyState._check_and_set_dependencies refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if) - Remove unreachable code (
remove-unreachable-code)
| dstring = str( | ||
| bytes(info["docstring"], "utf-8").decode("unicode_escape") | ||
| ) | ||
| dstring = bytes(info["docstring"], "utf-8").decode("unicode_escape") |
There was a problem hiding this comment.
Function TabPyState._add_update_endpoints_config refactored with the following changes:
- Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast)
| if len(deps) > 0: | ||
| if deps: |
There was a problem hiding this comment.
Function TabPyState.delete_endpoint refactored with the following changes:
- Simplify sequence length comparison (
simplify-len-comparison)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.24%.
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! Help us improve this quality report! |
Branch
masterrefactored 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
masterbranch, then run:Help us improve this pull request!