Jupyter notebook API typo (Sourcery refactored)#129
Conversation
| definition = {} | ||
| definition['name'] = cluster_name | ||
| definition['type'] = cluster_type | ||
| definition['params'] = params if params is not None else {} | ||
| definition = { | ||
| 'name': cluster_name, | ||
| 'type': cluster_type, | ||
| 'params': params if params is not None else {}, | ||
| } | ||
|
|
There was a problem hiding this comment.
Function DSSClient.create_cluster refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
| if isinstance(v, str) or isinstance(v, unicode): | ||
| if isinstance(v, (str, unicode)): |
There was a problem hiding this comment.
Function DSSClient.make_entry refactored with the following changes:
- Merge isinstance calls (
merge-is-instance)
| if not feature_name in self.mltask_settings["preprocessing"]["per_feature"]: | ||
| if ( | ||
| feature_name | ||
| not in self.mltask_settings["preprocessing"]["per_feature"] | ||
| ): |
There was a problem hiding this comment.
Function PredictionSplitParamsHandler.set_time_ordering refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan)
| if len(diagnostic) == 0: | ||
| if not diagnostic: |
There was a problem hiding this comment.
Function DSSMLTaskSettings.set_diagnostic_type_enabled refactored with the following changes:
- Simplify sequence comparison (
simplify-len-comparison)
| pretty_hyperparam = dict() | ||
| pretty_hyperparam = {} |
There was a problem hiding this comment.
Function NumericalHyperparameterSettings._pretty_repr refactored with the following changes:
- Replace dict() with {} (
dict-literal)
| if self.gt is not None: | ||
| repr_gt = "%s<" % self.gt | ||
| elif self.gte is not None: | ||
| repr_gt = "%s<=" % self.gte | ||
| else: | ||
| if self.gt is not None: | ||
| repr_gt = "%s<" % self.gt | ||
| elif self.gte is not None: | ||
| repr_gt = "%s<=" % self.gte | ||
| else: | ||
| repr_gt = "" | ||
| repr_gt = "" | ||
|
|
||
| if self.lte is not None: | ||
| repr_lt = "<=%s" % self.lte | ||
| else: | ||
| repr_lt = "" | ||
|
|
||
| return "DSSSubpopulationNumericModalityDefinition(%s%s%s)" % (repr_gt, self.feature_name, repr_lt) | ||
| repr_lt = "<=%s" % self.lte if self.lte is not None else "" | ||
| return "DSSSubpopulationNumericModalityDefinition(%s%s%s)" % (repr_gt, self.feature_name, repr_lt) |
There was a problem hiding this comment.
Function DSSSubpopulationNumericModalityDefinition.__repr__ refactored with the following changes:
- Remove unnecessary else after guard condition (
remove-unnecessary-else) - Replace if statement with if expression (
assign-if-exp)
| if len(modality_candidates) == 0: | ||
| if not modality_candidates: | ||
| raise ValueError("Modality with index '%s' not found" % definition.index) | ||
| return modality_candidates[0] | ||
|
|
There was a problem hiding this comment.
Function DSSSubpopulationAnalysis.get_modality_data refactored with the following changes:
- Simplify sequence comparison (
simplify-len-comparison)
| else: | ||
| if project_key is None: | ||
| project_key = match.group(1) | ||
| return DSSMLTask(client, project_key, match.group(2), match.group(3)) | ||
| if project_key is None: | ||
| project_key = match.group(1) | ||
| return DSSMLTask(client, project_key, match.group(2), match.group(3)) |
There was a problem hiding this comment.
Function DSSMLTask.from_full_model_id refactored with the following changes:
- Remove unnecessary else after guard condition (
remove-unnecessary-else)
| ref = self.client._perform_json("POST", "/projects/%s/duplicate/" % self.project_key, body = obj) | ||
| return ref | ||
| return self.client._perform_json( | ||
| "POST", "/projects/%s/duplicate/" % self.project_key, body=obj | ||
| ) |
There was a problem hiding this comment.
Function DSSProject.duplicate refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| if as_type == "listitems" or as_type == "listitem": | ||
| if as_type in ["listitems", "listitem"]: | ||
| return [DSSDatasetListItem(self.client, item) for item in items] | ||
| elif as_type == "objects" or as_type == "object": | ||
| elif as_type in ["objects", "object"]: |
There was a problem hiding this comment.
Function DSSProject.list_datasets refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
| if as_type == "listitems" or as_type == "listitem": | ||
| if as_type in ["listitems", "listitem"]: | ||
| return [DSSStreamingEndpointListItem(self.client, item) for item in items] | ||
| elif as_type == "objects" or as_type == "object": | ||
| elif as_type in ["objects", "object"]: |
There was a problem hiding this comment.
Function DSSProject.list_streaming_endpoints refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
| if as_type == "objects" or as_type == "object": | ||
| if as_type in ["objects", "object"]: |
There was a problem hiding this comment.
Function DSSProject.list_model_evaluation_stores refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
| if not "standard" in obj: | ||
| if "standard" not in obj: | ||
| raise ValueError("Missing 'standard' key in argument") | ||
| if not "local" in obj: | ||
| if "local" not in obj: |
There was a problem hiding this comment.
Function DSSProject.set_variables refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan)
| if as_type == "listitems" or as_type == "listitem": | ||
| if as_type in ["listitems", "listitem"]: | ||
| return [DSSRecipeListItem(self.client, item) for item in items] | ||
| elif as_type == "objects" or as_type == "object": | ||
| elif as_type in ["objects", "object"]: |
There was a problem hiding this comment.
Function DSSProject.list_recipes refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
| elif type == "prepare" or type == "shaker": | ||
| elif type in ["prepare", "shaker"]: |
There was a problem hiding this comment.
Function DSSProject.new_recipe refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
| already_exists = False | ||
| for rule in found_eo["rules"]: | ||
| if rule["targetProject"] == target_project: | ||
| already_exists = True | ||
| break | ||
| already_exists = any( | ||
| rule["targetProject"] == target_project for rule in found_eo["rules"] | ||
| ) |
There was a problem hiding this comment.
Function DSSProjectSettings.add_exposed_object refactored with the following changes:
- Use any() instead of for loop (
use-any)
| params = None | ||
| else: | ||
| params = { | ||
| params = None if project_key is None else { |
There was a problem hiding this comment.
Function DSSProjectDeployer.upload_bundle refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
defb145 to
08b4ab3
Compare
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.39%.
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! Let us know what you think of it by mentioning @sourcery-ai in a comment. |
Pull Request #128 refactored by Sourcery.
If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.
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
fix/dss90-jupyter-typobranch, then run: