From 3c55f7881742627f1763c002f8b68816e27d554c Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Sun, 1 Oct 2023 22:25:24 +0200 Subject: [PATCH] Chore: Update dependencies, satisfy linter, and format code --- pyproject.toml | 14 +++++++------- skeem/autopk.py | 1 - skeem/core.py | 3 --- skeem/ddlgen/monkey.py | 1 - skeem/ddlgen/sources.py | 3 ++- skeem/ddlgen/typehelpers.py | 2 +- skeem/util/platform.py | 1 - tests/test_core.py | 1 - tests/util.py | 2 +- 9 files changed, 11 insertions(+), 17 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1315c6b..d5cc907 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,16 +100,16 @@ classifiers = [ ] [project.optional-dependencies] develop = [ - "black<23", + "black<24", "hunter<4", - "mypy==0.991", - "poethepoet<0.19", - "pyproject-fmt<0.6", - "ruff==0.0.231", - "validate-pyproject<0.12", + "mypy==1.5.1", + "poethepoet<0.25", + "pyproject-fmt<1.2", + "ruff==0.0.291", + "validate-pyproject<0.15", ] release = [ - "build<1", + "build<2", 'minibump<1; python_version >= "3.10"', "twine<5", ] diff --git a/skeem/autopk.py b/skeem/autopk.py index 56bc03d..a6215fd 100644 --- a/skeem/autopk.py +++ b/skeem/autopk.py @@ -50,7 +50,6 @@ def infer_pk( def _infer_pk( data: t.Any, content_type: t.Optional[ContentType] = None, address: t.Optional[AddressType] = None ) -> t.Optional[str]: - # Try to converge data into pandas DataFrame. if isinstance(data, pd.DataFrame): df = data diff --git a/skeem/core.py b/skeem/core.py index 37400c8..3be35d0 100644 --- a/skeem/core.py +++ b/skeem/core.py @@ -75,7 +75,6 @@ def to_sql_ddl(self) -> SqlResult: raise NotImplementedError(f"Backend '{self.backend}' not implemented") def _ddl_frictionless(self) -> SqlResult: - # Suppress warnings of BeautifulSoup from bs4 import GuessedAtParserWarning @@ -118,7 +117,6 @@ def _ddl_frictionless(self) -> SqlResult: # TODO: Make `infer_pk` obtain a `Resource` instance, and/or refactor as method. # TODO: Optimize runtime by not needing to open the resource twice. if self.target.primary_key is None: - logger.info("Converging resource to pandas DataFrame") df: pd.DataFrame = resource.to_pandas() logger.info(f"pandas DataFrame size={len(df)}") @@ -158,7 +156,6 @@ def _ddl_frictionless(self) -> SqlResult: return SqlResult(sql) def _ddl_ddlgen(self) -> SqlResult: - from skeem.ddlgen.ddlgenerator import TablePlus from skeem.ddlgen.sources import SourcePlus diff --git a/skeem/ddlgen/monkey.py b/skeem/ddlgen/monkey.py index 93f4d03..542e291 100644 --- a/skeem/ddlgen/monkey.py +++ b/skeem/ddlgen/monkey.py @@ -8,7 +8,6 @@ def activate(): - ddlgenerator.ddlgenerator.mock_engines = AnyDialect() ddlgenerator.ddlgenerator.Table = TablePlus ddlgenerator.reshape.clean_key_name = clean_key_name diff --git a/skeem/ddlgen/sources.py b/skeem/ddlgen/sources.py index 4bc78c4..62c0cec 100644 --- a/skeem/ddlgen/sources.py +++ b/skeem/ddlgen/sources.py @@ -1,3 +1,4 @@ +import ast import io import logging import typing as t @@ -201,7 +202,7 @@ def _eval_grib2(target, fieldnames: t.List[str] = None, *args, **kwargs): candidates = msg.splitlines()[1:] candidate = candidates[0].strip() logger.info(f"WARNING: Falling back to '{candidate}'. Reason: {ex}") - kwargs = eval(f"dict({candidate})") + kwargs = ast.literal_eval(f"dict({candidate})") ds = xr.open_dataset(gribfile, engine="cfgrib", **kwargs, decode_times=False) else: raise diff --git a/skeem/ddlgen/typehelpers.py b/skeem/ddlgen/typehelpers.py index c8138ce..5e70625 100644 --- a/skeem/ddlgen/typehelpers.py +++ b/skeem/ddlgen/typehelpers.py @@ -77,7 +77,7 @@ def coerce_to_specific(datum: CoercionType) -> t.Optional[CoercionType]: if not (1700 < result.year < 2150): raise Exception("false date hit (%s) for %s" % (str(result), datum)) return result - except Exception: + except Exception: # noqa: S110 pass try: return int(str(datum)) diff --git a/skeem/util/platform.py b/skeem/util/platform.py index 736b473..b7a80f1 100644 --- a/skeem/util/platform.py +++ b/skeem/util/platform.py @@ -4,7 +4,6 @@ def about_platform(): - subsection("Python") print(bullet_item(platform.platform())) print() diff --git a/tests/test_core.py b/tests/test_core.py index 772749c..71f498b 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -48,7 +48,6 @@ def test_schema_generator_invalid_content_type(): @pytest.mark.xfail def test_schema_generator_without_resource_type(): - # Let's create a _valid_ `SchemaGenerator` instance first. sg = SchemaGenerator( resource=Resource(data=io.StringIO("a,b"), content_type="csv"), diff --git a/tests/util.py b/tests/util.py index 95807a6..e02559c 100644 --- a/tests/util.py +++ b/tests/util.py @@ -14,7 +14,7 @@ def random_table_name(label: t.Union[Path, str]): name = label if isinstance(label, Path): name = label.name - return f"skeem-test-{name}-{random.randint(1, 9999)}" + return f"skeem-test-{name}-{random.randint(1, 9999)}" # noqa: S311 def get_basic_sql_reference(