Skip to content

Commit

Permalink
trivial: bump ruff version and add rules
Browse files Browse the repository at this point in the history
JIRA: TRIVIAL
  • Loading branch information
hkad98 committed Apr 15, 2024
1 parent 34534b2 commit 8f5e804
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
args: [ '--maxkb=890' ]
- id: check-case-conflict
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
rev: v0.3.5
hooks:
# Run the linter.
- id: ruff
Expand Down
2 changes: 1 addition & 1 deletion fmt-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruff==0.3.3
ruff==0.3.5
2 changes: 1 addition & 1 deletion gooddata-dbt/gooddata_dbt/dbt/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, model_ids: Optional[List[str]], ldm: CatalogDeclarativeModel)
@property
def metrics(self) -> List[DbtModelMetric]:
result = []
for metric_name, metric_def in self.dbt_catalog["metrics"].items():
for metric_def in self.dbt_catalog["metrics"].values():
result.append(DbtModelMetric.from_dict(metric_def))
# Return only gooddata labelled tables marked by model_id (if requested in args)
return [
Expand Down
2 changes: 1 addition & 1 deletion gooddata-dbt/gooddata_dbt/dbt/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def from_local(
@staticmethod
def read_dbt_models(dbt_catalog: Dict, upper_case: bool, all_model_ids: List[str]) -> List[DbtModelTable]:
tables = []
for _, model_def in dbt_catalog["nodes"].items():
for model_def in dbt_catalog["nodes"].values():
model_id = safeget(model_def, ["meta", "gooddata", "model_id"])
if model_id in all_model_ids:
tables.append(DbtModelTable.from_dict(model_def))
Expand Down
2 changes: 1 addition & 1 deletion gooddata-fdw/gooddata_fdw/column_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def table_col_as_computable(col: ColumnDefinition) -> Union[Attribute, Metric]:
if item_type == "label":
return sdk.Attribute(local_id=col.column_name, label=item_id)
else:
aggregation = col.options["agg"] if "agg" in col.options else None
aggregation = col.options.get("agg")

return sdk.SimpleMetric(
local_id=col.column_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_metric(self, metric_id: Union[str, ObjId]) -> Union[CatalogMetric, None]
else:
obj_id_str = metric_id

return self._metric_idx[obj_id_str] if obj_id_str in self._metric_idx else None
return self._metric_idx.get(obj_id_str)

def get_dataset(self, dataset_id: Union[str, ObjId]) -> Union[CatalogDataset, None]:
"""
Expand All @@ -106,7 +106,7 @@ def get_dataset(self, dataset_id: Union[str, ObjId]) -> Union[CatalogDataset, No
else:
obj_id_str = dataset_id

return self._datasets_idx[obj_id_str] if obj_id_str in self._datasets_idx else None
return self._datasets_idx.get(obj_id_str)

def find_label_attribute(self, id_obj: IdObjType) -> Union[CatalogAttribute, None]:
"""Get attribute by label id."""
Expand Down
8 changes: 4 additions & 4 deletions gooddata-sdk/gooddata_sdk/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def _convert_filter_to_computable(filter_obj: dict[str, Any]) -> Filter:

if "comparison" in condition:
c = condition["comparison"]
treat_values_as_null = c["treatNullValuesAs"] if "treatNullValuesAs" in c else None
treat_values_as_null = c.get("treatNullValuesAs")

return MetricValueFilter(
metric=_ref_extract(f["measure"]),
Expand All @@ -233,7 +233,7 @@ def _convert_filter_to_computable(filter_obj: dict[str, Any]) -> Filter:
)
elif "range" in condition:
c = condition["range"]
treat_values_as_null = c["treatNullValuesAs"] if "treatNullValuesAs" in c else None
treat_values_as_null = c.get("treatNullValuesAs")
return MetricValueFilter(
metric=_ref_extract(f["measure"]),
operator=c["operator"],
Expand Down Expand Up @@ -268,7 +268,7 @@ def _convert_metric_to_computable(metric: dict[str, Any]) -> Metric:
if "measureDefinition" in measure_def:
d = measure_def["measureDefinition"]
aggregation = _AGGREGATION_CONVERSION[d["aggregation"]] if "aggregation" in d else None
compute_ratio = d["computeRatio"] if "computeRatio" in d else False
compute_ratio = d.get("computeRatio")

filters = [_convert_filter_to_computable(f) for f in d["filters"]] if "filters" in d else None

Expand Down Expand Up @@ -403,7 +403,7 @@ def label_id(self) -> str:

@property
def alias(self) -> Optional[str]:
return self._a["alias"] if "alias" in self._a else None
return self._a.get("alias")

@property
def label(self) -> dict[str, Any]:
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ lint.select = [
"E", # pycodestyle errors
"F", # pyflakes
"I", # isort
"PERF102", # perflint
"PIE",
"PLR0402", # prevent unnecessary manual import aliases
"PLR1711", # prevent useless returns
"SIM2", # simplify boolean expressions
"SIM4", # simplify if statements
"SIM9", # simplify dict values
"W" # pycodestyle warnings
]

Expand Down
2 changes: 1 addition & 1 deletion scripts/docs/json_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def signature_data(sig: inspect.Signature) -> SignatureData:
"""
sig_params_data = []

for name, param in sig.parameters.items():
for param in sig.parameters.values():
annotation = param.annotation
if annotation == inspect.Parameter.empty:
annotation = None
Expand Down
2 changes: 1 addition & 1 deletion scripts/docs/python_ref_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _recursive_create(data_root: dict, dir_root: Path, api_ref_root: str, module
links[name] = {"path": f"{api_ref_root}/{name}".lower(), "kind": "class"} # Lowercase for Hugo

elif name == "functions":
for func_name, func in obj.items():
for func_name in obj.keys():
if func_name.startswith("_"):
continue # Skip magic and private methods

Expand Down
6 changes: 2 additions & 4 deletions tests-support/upload_demo_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

def rest_op(op, url_path, data=None, raise_ex=True):
all_headers = {
**{
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
},
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
**headers,
}
url = f"{host}/{url_path}"
Expand Down

0 comments on commit 8f5e804

Please sign in to comment.