Skip to content

Commit

Permalink
feat: Lin with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
dmartinol committed Mar 26, 2024
1 parent cf58ebe commit 82e91cd
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 130 deletions.
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -317,17 +317,11 @@ test-python-universal:
FEAST_USAGE=False IS_TEST=True python -m pytest -n 8 --integration sdk/python/tests

format-python:
# Sort
cd ${ROOT_DIR}/sdk/python; python -m isort feast/ tests/

# Format
cd ${ROOT_DIR}/sdk/python; python -m black --target-version py38 feast tests
cd ${ROOT_DIR}/sdk/python; python -m ruff check --fix feast/ tests/

lint-python:
cd ${ROOT_DIR}/sdk/python; python -m mypy feast
cd ${ROOT_DIR}/sdk/python; python -m isort feast/ tests/ --check-only
cd ${ROOT_DIR}/sdk/python; python -m flake8 feast/ tests/
cd ${ROOT_DIR}/sdk/python; python -m black --check feast tests
cd ${ROOT_DIR}/sdk/python; python -m ruff check feast/ tests/

# Java

Expand Down
4 changes: 2 additions & 2 deletions docs/project/development-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ docker build -t docker-whale -f ./sdk/python/feast/infra/feature_servers/multicl
Feast Python SDK / CLI codebase:
- Conforms to [Black code style](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html)
- Has type annotations as enforced by `mypy`
- Has imports sorted by `isort`
- Is lintable by `flake8`
- Has imports sorted by `ruff` (see [isort (I) rules](https://docs.astral.sh/ruff/rules/#isort-i))
- Is lintable by `ruff`

To ensure your Python code conforms to Feast Python code standards:
- Autoformat your code to conform to the code style:
Expand Down
3 changes: 2 additions & 1 deletion sdk/python/feast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _version
except ModuleNotFoundError:
from importlib_metadata import PackageNotFoundError, version as _version # type: ignore
from importlib_metadata import PackageNotFoundError # type: ignore
from importlib_metadata import version as _version

from feast.infra.offline_stores.bigquery_source import BigQuerySource
from feast.infra.offline_stores.contrib.athena_offline_store.athena_source import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

import pyarrow as pa
import pyarrow.parquet as pq

from bytewax.dataflow import Dataflow # type: ignore
from bytewax.execution import cluster_main
from bytewax.inputs import ManualInputConfig
from bytewax.outputs import ManualOutputConfig

from feast import FeatureStore, FeatureView, RepoConfig
from feast.utils import _convert_arrow_to_proto, _run_pyarrow_field_mapping

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
from typing import Callable, List, Literal, Sequence, Union

import yaml
from kubernetes import client
from kubernetes import client, utils
from kubernetes import config as k8s_config
from kubernetes import utils
from kubernetes.client.exceptions import ApiException
from kubernetes.utils import FailToCreateError
from pydantic import StrictStr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Callable, List, Literal, Optional, Sequence, Union, cast

import dill
import pandas
import pandas as pd
import pyarrow
from tqdm import tqdm
Expand Down
15 changes: 15 additions & 0 deletions sdk/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.ruff]
exclude = [".git","__pycache__","docs/conf.py","dist","feast/protos","feast/embedded_go/lib","feast/infra/utils/snowflake/snowpark/snowflake_udfs.py"]

[tool.ruff.lint]
select = ["E","F","W","I"]
ignore = ["E203", "E266", "E501", "E721"]

[tool.ruff.lint.isort]
known-first-party = ["feast", "feast", "feast_serving_server", "feast_core_server"]
default-section = "third-party"

[tool.mypy]
files = ["feast","tests"]
ignore_missing_imports = true
exclude = ["feast/embedded_go/lib"]
25 changes: 5 additions & 20 deletions sdk/python/requirements/py3.10-ci-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ anyio==4.3.0
# watchfiles
appdirs==1.4.4
# via fissix
appnope==0.1.4
# via ipykernel
argon2-cffi==23.1.0
# via jupyter-server
argon2-cffi-bindings==21.2.0
Expand Down Expand Up @@ -57,8 +59,6 @@ beautifulsoup4==4.12.3
# via nbconvert
bidict==0.23.1
# via ibis-framework
black==22.12.0
# via feast (setup.py)
bleach==6.1.0
# via nbconvert
boto3==1.34.65
Expand Down Expand Up @@ -105,7 +105,6 @@ charset-normalizer==3.3.2
# snowflake-connector-python
click==8.1.7
# via
# black
# bowler
# dask
# feast (setup.py)
Expand Down Expand Up @@ -187,8 +186,6 @@ firebase-admin==5.4.0
# via feast (setup.py)
fissix==21.11.13
# via bowler
flake8==6.0.0
# via feast (setup.py)
fqdn==1.5.1
# via jsonschema
fsspec==2023.12.2
Expand Down Expand Up @@ -348,8 +345,6 @@ isodate==0.6.1
# via azure-storage-blob
isoduration==20.11.0
# via jsonschema
isort==5.13.2
# via feast (setup.py)
jedi==0.19.1
# via ipython
jinja2==3.1.3
Expand Down Expand Up @@ -441,8 +436,6 @@ matplotlib-inline==0.1.6
# via
# ipykernel
# ipython
mccabe==0.7.0
# via flake8
mdurl==0.1.2
# via markdown-it-py
minio==7.1.0
Expand Down Expand Up @@ -476,9 +469,7 @@ mypy==1.9.0
# feast (setup.py)
# sqlalchemy
mypy-extensions==1.0.0
# via
# black
# mypy
# via mypy
mypy-protobuf==3.3.0
# via feast (setup.py)
nbclient==0.10.0
Expand Down Expand Up @@ -553,8 +544,6 @@ parsy==2.1
# via ibis-framework
partd==1.4.1
# via dask
pathspec==0.12.1
# via black
pbr==6.0.0
# via mock
pexpect==4.9.0
Expand All @@ -563,7 +552,6 @@ pip-tools==7.4.1
# via feast (setup.py)
platformdirs==3.11.0
# via
# black
# jupyter-core
# snowflake-connector-python
# virtualenv
Expand Down Expand Up @@ -640,8 +628,6 @@ pyasn1-modules==0.3.0
# via google-auth
pybindgen==0.22.1
# via feast (setup.py)
pycodestyle==2.10.0
# via flake8
pycparser==2.21
# via cffi
pydantic==2.6.4
Expand All @@ -651,8 +637,6 @@ pydantic==2.6.4
# great-expectations
pydantic-core==2.16.3
# via pydantic
pyflakes==3.0.1
# via flake8
pygments==2.17.2
# via
# feast (setup.py)
Expand Down Expand Up @@ -797,6 +781,8 @@ rsa==4.9
# via google-auth
ruamel-yaml==0.17.17
# via great-expectations
ruff==0.3.4
# via feast (setup.py)
s3transfer==0.10.1
# via boto3
scipy==1.12.0
Expand Down Expand Up @@ -874,7 +860,6 @@ toml==0.10.2
# via feast (setup.py)
tomli==2.0.1
# via
# black
# build
# coverage
# jupyterlab
Expand Down
37 changes: 11 additions & 26 deletions sdk/python/requirements/py3.8-ci-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ anyio==4.3.0
# watchfiles
appdirs==1.4.4
# via fissix
appnope==0.1.4
# via
# ipykernel
# ipython
argon2-cffi==23.1.0
# via jupyter-server
argon2-cffi-bindings==21.2.0
Expand All @@ -41,8 +45,6 @@ attrs==23.2.0
# bowler
# jsonschema
# referencing
avro==1.11.3
# via feast (setup.py)
azure-core==1.30.1
# via
# azure-identity
Expand All @@ -63,8 +65,6 @@ backports-zoneinfo==0.2.1
# tzlocal
beautifulsoup4==4.12.3
# via nbconvert
black==22.12.0
# via feast (setup.py)
bleach==6.1.0
# via nbconvert
boto3==1.34.60
Expand Down Expand Up @@ -111,7 +111,6 @@ charset-normalizer==3.3.2
# snowflake-connector-python
click==8.1.7
# via
# black
# bowler
# dask
# feast (setup.py)
Expand Down Expand Up @@ -192,8 +191,6 @@ firebase-admin==5.4.0
# via feast (setup.py)
fissix==21.11.13
# via bowler
flake8==6.0.0
# via feast (setup.py)
fqdn==1.5.1
# via jsonschema
fsspec==2023.12.2
Expand Down Expand Up @@ -365,8 +362,6 @@ isodate==0.6.1
# via azure-storage-blob
isoduration==20.11.0
# via jsonschema
isort==5.13.2
# via feast (setup.py)
jedi==0.19.1
# via ipython
jinja2==3.1.3
Expand Down Expand Up @@ -458,8 +453,6 @@ matplotlib-inline==0.1.6
# via
# ipykernel
# ipython
mccabe==0.7.0
# via flake8
mdurl==0.1.2
# via markdown-it-py
minio==7.1.0
Expand Down Expand Up @@ -493,9 +486,7 @@ mypy==1.9.0
# feast (setup.py)
# sqlalchemy
mypy-extensions==1.0.0
# via
# black
# mypy
# via mypy
mypy-protobuf==3.3.0
# via feast (setup.py)
nbclient==0.9.1
Expand Down Expand Up @@ -553,7 +544,7 @@ packaging==24.0
# pytest
# snowflake-connector-python
# sphinx
pandas==1.5.3 ; python_version < "3.9"
pandas==1.5.3
# via
# altair
# db-dtypes
Expand All @@ -570,8 +561,6 @@ parsy==2.1
# via ibis-framework
partd==1.4.1
# via dask
pathspec==0.12.1
# via black
pbr==6.0.0
# via mock
pexpect==4.9.0
Expand All @@ -584,7 +573,6 @@ pkgutil-resolve-name==1.3.10
# via jsonschema
platformdirs==3.11.0
# via
# black
# jupyter-core
# snowflake-connector-python
# virtualenv
Expand All @@ -602,7 +590,6 @@ prompt-toolkit==3.0.43
# via ipython
proto-plus==1.23.0
# via
# feast (setup.py)
# google-cloud-bigquery
# google-cloud-bigquery-storage
# google-cloud-bigtable
Expand Down Expand Up @@ -659,8 +646,6 @@ pyasn1-modules==0.3.0
# via google-auth
pybindgen==0.22.1
# via feast (setup.py)
pycodestyle==2.10.0
# via flake8
pycparser==2.21
# via cffi
pydantic==2.6.4
Expand All @@ -670,8 +655,6 @@ pydantic==2.6.4
# great-expectations
pydantic-core==2.16.3
# via pydantic
pyflakes==3.0.1
# via flake8
pygments==2.17.2
# via
# feast (setup.py)
Expand Down Expand Up @@ -819,6 +802,8 @@ ruamel-yaml==0.17.17
# via great-expectations
ruamel-yaml-clib==0.2.8
# via ruamel-yaml
ruff==0.3.4
# via feast (setup.py)
s3transfer==0.10.0
# via boto3
scipy==1.10.1
Expand Down Expand Up @@ -866,7 +851,9 @@ sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
# via sphinx
sqlalchemy[mypy]==1.4.52
# via feast (setup.py)
# via
# feast (setup.py)
# sqlalchemy
sqlalchemy2-stubs==0.0.2a38
# via sqlalchemy
sqlglot==10.6.4
Expand All @@ -893,7 +880,6 @@ toml==0.10.2
# via feast (setup.py)
tomli==2.0.1
# via
# black
# build
# coverage
# jupyterlab
Expand Down Expand Up @@ -973,7 +959,6 @@ typing-extensions==4.10.0
# async-lru
# azure-core
# azure-storage-blob
# black
# fastapi
# great-expectations
# ibis-framework
Expand Down
Loading

0 comments on commit 82e91cd

Please sign in to comment.