Skip to content

Commit 731bdbe

Browse files
style: upgrade pylint and dependencies and fix linting following upgrade
1 parent 10d5dc4 commit 731bdbe

11 files changed

Lines changed: 229 additions & 398 deletions

File tree

poetry.lock

Lines changed: 193 additions & 247 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pylint_checkers/check_typing_imports.py

Lines changed: 0 additions & 113 deletions
This file was deleted.

pyproject.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ optional = true
7878

7979
[tool.poetry.group.lint.dependencies]
8080
black = "24.3.0"
81-
astroid = "2.14.2"
81+
astroid = "3.3.9"
8282
isort = "5.11.5"
83-
pylint = "2.16.4"
83+
pylint = "3.3.9"
8484
mypy = "0.991"
8585
boto3-stubs = {extras = ["essential"], version = "1.26.72"}
8686
botocore-stubs = "1.29.72"
@@ -142,10 +142,6 @@ source_pkgs = [
142142
[tool.coverage.report]
143143
show_missing = true
144144

145-
[tool.pylint]
146-
init-hook = "import sys; sys.path.append('./pylint_checkers')"
147-
load-plugins = "check_typing_imports"
148-
149145
[tool.pylint.main]
150146
extension-pkg-allow-list = ["pyspark", "lxml", "pydantic"]
151147
fail-under = 10.0
@@ -194,7 +190,7 @@ max-statements = 50
194190
min-public-methods = 2
195191

196192
[tool.pylint.exceptions]
197-
overgeneral-exceptions = ["BaseException", "Exception"]
193+
overgeneral-exceptions = ["builtins.BaseException", "builtins.Exception"]
198194

199195
[tool.pylint.format]
200196
ignore-long-lines = "^\\s*(# )?<?https?://\\S+>?$"
@@ -229,6 +225,8 @@ disable = [
229225
"use-symbolic-message-instead",
230226
"logging-fstring-interpolation",
231227
"fixme",
228+
"too-many-positional-arguments",
229+
"too-many-arguments",
232230
]
233231
enable = ["c-extension-no-member"]
234232

src/dve/core_engine/backends/implementations/duckdb/rules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def _add_cnst_field(rel: DuckDBPyRelation) -> tuple[str, DuckDBPyRelation]:
152152
group_pl = entity.pl().pivot(
153153
columns=[config.pivot_column],
154154
values=agg_cols,
155-
index=(group_cols or [const_fld]),
155+
index=(group_cols or [const_fld]), # pylint: disable=E0606
156156
aggregate_function=config.agg_function,
157157
)
158158
if const_fld in group_pl.columns:

src/dve/core_engine/backends/metadata/contract.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def schemas(self) -> dict[EntityName, type[BaseModel]]:
4444
"""The per-entity schemas, as pydantic models."""
4545
if not self._schemas:
4646
for entity_name, validator in self.validators.items():
47-
self._schemas[entity_name] = validator.model # type: ignore
48-
return self._schemas.copy()
47+
self._schemas[entity_name] = validator.model # type: ignore # pylint: disable=E1137
48+
return self._schemas.copy() # pylint: disable=E1101
4949

5050
@root_validator(allow_reuse=True)
5151
@classmethod

src/dve/core_engine/configuration/v1/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
FieldName = str
4040
"""The name of a field within a model/schema."""
41-
TypeOrDef = Union[
41+
TypeOrDef = Union[ # pylint: disable=C0103
4242
TypeName, "_CallableTypeDefinition", "_ModelTypeDefinition", "_TypeAliasDefinition"
4343
]
4444
"""The name or definition of a type."""
@@ -181,7 +181,7 @@ class V1EngineConfig(BaseEngineConfig):
181181
@validate_arguments
182182
def _update_rule_store(self, rule_store: dict[RuleName, BusinessComponentSpecConfigUnion]):
183183
"""Update the rule store rules to add/override the rules from the new store."""
184-
self._rule_store_rules.update(rule_store)
184+
self._rule_store_rules.update(rule_store) # pylint: disable=E1101
185185

186186
def _load_rule_store(self, uri: URI):
187187
"""Load a JSON rule store from the provided URI and update the stored
@@ -198,7 +198,7 @@ def _load_rule_store(self, uri: URI):
198198
def __init__(self, *args, **kwargs):
199199
super().__init__(*args, **kwargs)
200200
uri_prefix = self.location.rsplit("/", 1)[0]
201-
for rule_store_config in self.transformations.rule_stores:
201+
for rule_store_config in self.transformations.rule_stores: # pylint: disable=E1101
202202
uri = joinuri(uri_prefix, rule_store_config.filename)
203203
self._load_rule_store(uri)
204204

@@ -281,7 +281,7 @@ def _load_rules_and_vars(self) -> tuple[list[Rule], list[TemplateVariables]]:
281281
rules, local_variable_list = [], []
282282
added_rules: set[RuleName] = set()
283283

284-
for index, complex_rule_config in enumerate(self.transformations.complex_rules):
284+
for index, complex_rule_config in enumerate(self.transformations.complex_rules): # pylint: disable=E1101
285285
rule, local_params, deps = self._resolve_business_rule(complex_rule_config)
286286
missing_rules = deps - added_rules
287287
if missing_rules:
@@ -295,9 +295,9 @@ def _load_rules_and_vars(self) -> tuple[list[Rule], list[TemplateVariables]]:
295295

296296
rule, local_params = self._create_rule(
297297
name="root",
298-
rules=self.transformations.rules,
299-
filters=self.transformations.filters,
300-
post_filter_rules=self.transformations.post_filter_rules,
298+
rules=self.transformations.rules, # pylint: disable=E1101
299+
filters=self.transformations.filters, # pylint: disable=E1101
300+
post_filter_rules=self.transformations.post_filter_rules, # pylint: disable=E1101
301301
)
302302
rules.append(rule)
303303
local_variable_list.append(local_params)
@@ -338,14 +338,14 @@ def load_error_message_info(self, uri):
338338

339339
def get_reference_data_config(self) -> dict[EntityName, ReferenceConfig]: # type: ignore
340340
"""Gets the reference data configuration from the transformations"""
341-
return self.transformations.reference_data
341+
return self.transformations.reference_data # pylint: disable=E1101
342342

343343
def get_rule_metadata(self) -> RuleMetadata:
344344
"""Gets the rule metadata from the Engine configuration"""
345345
rules, local_variables = self._load_rules_and_vars()
346346
return RuleMetadata(
347347
rules=rules,
348348
local_variables=local_variables,
349-
global_variables=self.transformations.parameters,
349+
global_variables=self.transformations.parameters, # pylint: disable=E1101
350350
reference_data_config=self.get_reference_data_config(),
351351
)

src/dve/core_engine/engine.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def build(
137137
debug=debug,
138138
**kwargs,
139139
)
140-
self.main_log.info(f"Output path: {self.output_prefix_uri!r}")
140+
self.main_log.info(f"Output path: {self.output_prefix_uri!r}") # pylint: disable=E1101
141141
return self
142142

143143
@classmethod
@@ -155,13 +155,13 @@ def build_from_model(cls, model_str: JSONstring):
155155
return cls.build(**EngineRunValidation(**json.loads(model_str)).dict())
156156

157157
def __enter__(self) -> "CoreEngine":
158-
self.main_log.info("Entering pipeline context.")
158+
self.main_log.info("Entering pipeline context.") # pylint: disable=E1101
159159
if self._cache_dir is not None:
160160
raise ValueError("Pipeline already within context")
161161

162162
self._cache_dir = TemporaryPrefix(self.cache_prefix_uri)
163163
self._cache_dir.__enter__()
164-
self.main_log.info(f"Pipeline will cache to {self.cache_prefix!r}")
164+
self.main_log.info(f"Pipeline will cache to {self.cache_prefix!r}") # pylint: disable=E1101
165165
return self
166166

167167
def __exit__(
@@ -170,14 +170,14 @@ def __exit__(
170170
exc_value: Optional[Exception],
171171
traceback: Optional[TracebackType],
172172
) -> None:
173-
self.main_log.info(f"Exiting pipeline context, clearing {self.cache_prefix!r}")
173+
self.main_log.info(f"Exiting pipeline context, clearing {self.cache_prefix!r}") # pylint: disable=E1101
174174
cache_dir = self._cache_dir
175175
self._cache_dir = None
176176

177177
if cache_dir is not None:
178178
cache_dir.__exit__(exc_type, exc_value, traceback)
179179

180-
self.main_log.info("Cleared cache.")
180+
self.main_log.info("Cleared cache.") # pylint: disable=E1101
181181

182182
@property
183183
def cache_prefix(self) -> URI:
@@ -198,17 +198,17 @@ def _write_entity_outputs(self, entities: SparkEntities) -> SparkEntities:
198198
"""
199199
output_entities = {}
200200

201-
self.main_log.info(f"Writing entities to the output location: {self.output_prefix_uri}")
201+
self.main_log.info(f"Writing entities to the output location: {self.output_prefix_uri}") # pylint: disable=E1101
202202
for entity_name, entity in entities.items():
203203
entity = entity.drop(RECORD_INDEX_COLUMN_NAME)
204204

205-
self.main_log.info(f"Entity: {entity_name} {type(entity)}")
205+
self.main_log.info(f"Entity: {entity_name} {type(entity)}") # pylint: disable=E1101
206206

207207
output_uri = joinuri(self.output_prefix_uri, entity_name)
208208
if get_resource_exists(output_uri):
209-
self.main_log.info(f"{output_uri} already exists - will be overwritten")
209+
self.main_log.info(f"{output_uri} already exists - will be overwritten") # pylint: disable=E1101
210210

211-
self.main_log.info(f"+ Writing parquet output to {output_uri!r}")
211+
self.main_log.info(f"+ Writing parquet output to {output_uri!r}") # pylint: disable=E1101
212212
entity.write.mode("overwrite").parquet(output_uri)
213213
spark_session = SparkSession.builder.getOrCreate()
214214
output_entities[entity_name] = spark_session.read.format("parquet").load(
@@ -228,7 +228,7 @@ def _write_outputs(self, entities: SparkEntities) -> SparkEntities:
228228

229229
def _show_available_entities(self, entities: SparkEntities, *, verbose: bool = False) -> None:
230230
"""Print current entities."""
231-
self.main_log.info("Displaying available dataframes in this run:")
231+
self.main_log.info("Displaying available dataframes in this run:") # pylint: disable=E1101
232232

233233
for entity_name, entity in entities.items():
234234
# FIXME: Currently a print statement because log messages

src/dve/core_engine/type_hints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from multiprocessing import Queue as ProcessQueue
66
from pathlib import Path
77
from queue import Queue as ThreadQueue
8-
from typing import TYPE_CHECKING, Any, List, Optional, TypeVar, Union # pylint: disable=W1901
8+
from typing import TYPE_CHECKING, Any, List, Optional, TypeVar, Union
99

1010
from pyspark.sql import DataFrame
1111
from pyspark.sql.types import StructType

src/dve/metadata_parser/domain_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def check_validates(cls, value: Optional[str]) -> bool:
152152
return is_valid
153153

154154
@classmethod
155-
def validate(cls, value: Optional[str], field: fields.ModelField) -> str: # type: ignore
155+
def validate(cls, value: Optional[str], field: fields.ModelField) -> str: # type: ignore # pylint: disable=W0221
156156
"""Validates the given postcode"""
157157
nhs_number = cls.ensure_format(value)
158158

src/dve/metadata_parser/models.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ def validate_error_message(cls, value: str, values: dict[str, Any]) -> str:
8181
def get_field_validator(self, field_name: str, **extra_kwargs: Any) -> classmethod:
8282
"""Get a validator a given field."""
8383
func = getattr(function_library, self.name)
84+
_kwargs = self.kwargs_ | extra_kwargs
8485
return create_validator(
8586
func,
8687
field_name,
8788
exc.ERRORS[self.error_type.replace("_", "")],
8889
self.error_message,
8990
return_result=True,
9091
fields=self.fields,
91-
**self.kwargs_,
92-
**extra_kwargs,
92+
**_kwargs,
9393
)
9494

9595

@@ -257,7 +257,7 @@ def get_type_and_validators(
257257
python_type_callable = chain_get(self.callable, *type_mappings, pyd, dt, __builtins__)
258258
if not callable(python_type_callable):
259259
raise ValueError("Fetched callable is not callable")
260-
python_type = python_type_callable(**self.constraints)
260+
python_type = python_type_callable(**self.constraints) # pylint: disable=E1134
261261
else:
262262
raise ValueError("No field type set")
263263

@@ -360,7 +360,7 @@ def as_model(
360360
field_name,
361361
*type_mappings,
362362
schemas=schemas,
363-
is_mandatory=field_name in self.mandatory_fields,
363+
is_mandatory=field_name in self.mandatory_fields, # pylint: disable=E1135
364364
)
365365
pyd_fields[field_name] = (python_type, default)
366366
validators.update(field_validators)
@@ -398,7 +398,7 @@ def load_models(
398398
) -> dict[EntityName, pyd.main.ModelMetaclass]:
399399
"""Load the models from the dataset definition."""
400400
loaded_schemas: dict[EntityName, pyd.main.ModelMetaclass] = {}
401-
for model_name, specification in self.schemas.items():
401+
for model_name, specification in self.schemas.items(): # pylint: disable=E1101
402402
loaded_schemas[model_name] = specification.as_model(
403403
model_name, self.types, *type_mappings, schemas=loaded_schemas
404404
)

0 commit comments

Comments
 (0)