From 315073e27c09596163acbccdd163d9ca921b65bc Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Wed, 20 Sep 2023 15:07:16 +0100 Subject: [PATCH] Remove print statement and add linting (#45) * Remove print statement and add linting * import future to ensure backward compatbiltity * fix imports * add dummy migration guide to prevent linkcheck failure --- .pre-commit-config.yaml | 8 +++----- README.md | 4 ++-- docs/source/migration_guide.md | 0 kedro_pandera/framework/cli/cli.py | 5 +++-- kedro_pandera/framework/config/resolvers.py | 1 - kedro_pandera/framework/hooks/pandera_hook.py | 2 +- pyproject.toml | 4 ++++ .../{{ cookiecutter.repo_name }}/conf/README.md | 2 +- 8 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 docs/source/migration_guide.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6368ba5..4b30ef0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,12 +7,10 @@ repos: rev: v0.0.277 hooks: - id: ruff - name: "ruff on tests/ and docs/" - # PLR2004: Magic value used - # PLR0913: Too many arguments - args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix", "--ignore=PLR2004,PLR0913"] + name: "Ruff" + args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"] # include: "tests" - exclude: "^kedro/templates/|^features/steps/test_starter/|kedro" + # exclude: "" - repo: https://github.com/psf/black rev: 23.7.0 hooks: diff --git a/README.md b/README.md index 48c2689..b7c23ef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ **General informations** -[![Python Version](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10-blue.svg)](https://pypi.org/project/kedro-pandera/) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Code Style: Black](https://img.shields.io/badge/code%20style-black-black.svg)](https://github.com/ambv/black) +[![Python Version](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10-blue.svg)](https://pypi.org/project/kedro-pandera/) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/license/apache-2-0/) [![Code Style: Black](https://img.shields.io/badge/code%20style-black-black.svg)](https://github.com/ambv/black) [![SemVer](https://img.shields.io/badge/semver-2.0.0-green)](https://semver.org/) ---------------------------------------------------------- @@ -48,7 +48,7 @@ The [release history](https://github.com/Galileo-Galilei/kedro-pandera/blob/main This package is still in active development. We use [SemVer](https://semver.org/) principles to version our releases. Until we reach `1.0.0` milestone, breaking changes will lead to `` version number increment, while releases which do not introduce breaking changes in the API will lead to `` version number increment. -If you want to see how to migrate from one version of `kedro-pandera` to another, see the [migration guide](../docs/migration_guide.md). +If you want to see how to migrate from one version of `kedro-pandera` to another, see the [migration guide](./docs/source/migration_guide.md). # Can I contribute? diff --git a/docs/source/migration_guide.md b/docs/source/migration_guide.md new file mode 100644 index 0000000..e69de29 diff --git a/kedro_pandera/framework/cli/cli.py b/kedro_pandera/framework/cli/cli.py index 314f50a..70845f6 100644 --- a/kedro_pandera/framework/cli/cli.py +++ b/kedro_pandera/framework/cli/cli.py @@ -1,5 +1,6 @@ +from __future__ import annotations + from pathlib import Path -from typing import Optional import click import frictionless # noqa: F401 @@ -63,7 +64,7 @@ def infer_dataset_schema( dataset_name: str, use_python_ext: bool = False, env: str = "base", - outfile: Optional[str] = None, + outfile: str | None = None, ): """Infer the schema of a dataset and dump it in a catalog file so that it will enable validation at runtime. diff --git a/kedro_pandera/framework/config/resolvers.py b/kedro_pandera/framework/config/resolvers.py index beb1c81..0a58fc9 100644 --- a/kedro_pandera/framework/config/resolvers.py +++ b/kedro_pandera/framework/config/resolvers.py @@ -32,5 +32,4 @@ def resolve_dataframe_model(schema_name): module, _, schema = schema_name.rpartition(".") module = importlib.import_module(module) - print(f"{module=} {getattr(module, schema)=}") return getattr(module, schema) diff --git a/kedro_pandera/framework/hooks/pandera_hook.py b/kedro_pandera/framework/hooks/pandera_hook.py index 5f1acd4..28af98a 100644 --- a/kedro_pandera/framework/hooks/pandera_hook.py +++ b/kedro_pandera/framework/hooks/pandera_hook.py @@ -5,9 +5,9 @@ from pandera.errors import SchemaError from kedro_pandera.framework.config.resolvers import ( + resolve_dataframe_model, resolve_interpolated_yaml_schema, resolve_yaml_schema, - resolve_dataframe_model, ) # if we do not import ``frictionless`` manually here, we get diff --git a/pyproject.toml b/pyproject.toml index e4b65c6..c56c004 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,10 @@ select = [ "UP", # pyupgrade "I", # isort "PL", # Pylint + "T201", # Print Statement ] ignore = ["E501"] # Black take care off line-too-long unfixable = [] + +[tool.ruff.per-file-ignores] +"{tests,docs}/*" = ["T201"] # Check print statement for kedro/ only diff --git a/tests/_data/pandas-iris/{{ cookiecutter.repo_name }}/conf/README.md b/tests/_data/pandas-iris/{{ cookiecutter.repo_name }}/conf/README.md index a6a80a4..fe4323f 100644 --- a/tests/_data/pandas-iris/{{ cookiecutter.repo_name }}/conf/README.md +++ b/tests/_data/pandas-iris/{{ cookiecutter.repo_name }}/conf/README.md @@ -23,4 +23,4 @@ WARNING: Please do not put access credentials in the base configuration folder. ## Find out more -You can find out more about configuration from the [user guide documentation](https://kedro.readthedocs.io/en/stable/user_guide/configuration.html). +You can find out more about configuration from the [user guide documentation](https://docs.kedro.org/en/stable/configuration/configuration_basics.html).