Skip to content

Commit

Permalink
chore: Move Python formatting and linting checks to ruff (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonLuttenberger authored Mar 7, 2024
1 parent 7b7eea3 commit 1d3f733
Show file tree
Hide file tree
Showing 37 changed files with 234 additions and 469 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### **Changed**

- refactor validation script to use `ruff` instead of `black` and `isort`

### **Removed**
46 changes: 19 additions & 27 deletions modules/mlflow/mlflow-fargate/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
[tool.black]
[tool.ruff]
exclude = [
".eggs",
".git",
".hg",
".mypy_cache",
".ruff_cache",
".tox",
".venv",
"_build",
"buck-out",
"build",
"dist",
"codeseeder",
]
line-length = 120
target-version = ["py38", "py39", "py310"]
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| \.env
| _build
| buck-out
| build
| dist
| codeseeder.out
)/
'''
target-version = "py38"

[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 120
py_version = 38
skip_gitignore = false
[tool.ruff.lint]
select = ["F", "I", "E", "W"]
fixable = ["ALL"]

[tool.mypy]
python_version = "3.8"
Expand Down
4 changes: 1 addition & 3 deletions modules/mlflow/mlflow-fargate/requirements-dev.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
awscli
black
cdk-nag
cfn-lint
check-manifest
flake8
isort
mypy
pip-tools
pydot
pyroma
pytest
ruff
types-PyYAML
types-setuptools
29 changes: 4 additions & 25 deletions modules/mlflow/mlflow-fargate/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ aws-sam-translator==1.84.0
# via cfn-lint
awscli==1.32.41
# via -r requirements-dev.in
black==24.2.0
# via -r requirements-dev.in
boto3==1.34.41
# via aws-sam-translator
botocore==1.34.41
Expand All @@ -53,9 +51,7 @@ charset-normalizer==3.3.2
check-manifest==0.49
# via -r requirements-dev.in
click==8.1.7
# via
# black
# pip-tools
# via pip-tools
colorama==0.4.4
# via awscli
constructs==10.3.0
Expand All @@ -70,8 +66,6 @@ exceptiongroup==1.2.0
# via
# cattrs
# pytest
flake8==7.0.0
# via -r requirements-dev.in
idna==3.6
# via requests
importlib-metadata==7.0.1
Expand All @@ -80,8 +74,6 @@ importlib-resources==6.1.1
# via jsii
iniconfig==2.0.0
# via pytest
isort==5.13.2
# via -r requirements-dev.in
jmespath==1.0.1
# via
# boto3
Expand Down Expand Up @@ -110,34 +102,25 @@ jsonschema-specifications==2023.12.1
# via jsonschema
junit-xml==1.9
# via cfn-lint
mccabe==0.7.0
# via flake8
mpmath==1.3.0
# via sympy
mypy==1.8.0
# via -r requirements-dev.in
mypy-extensions==1.0.0
# via
# black
# mypy
# via mypy
networkx==3.2.1
# via cfn-lint
packaging==23.2
# via
# black
# build
# pyroma
# pytest
pathspec==0.12.1
# via black
pbr==6.0.0
# via
# jschema-to-python
# sarif-om
pip-tools==7.3.0
# via -r requirements-dev.in
platformdirs==4.2.0
# via black
pluggy==1.4.0
# via pytest
publication==0.0.3
Expand All @@ -151,16 +134,12 @@ publication==0.0.3
# jsii
pyasn1==0.5.1
# via rsa
pycodestyle==2.11.1
# via flake8
pydantic==2.6.1
# via aws-sam-translator
pydantic-core==2.16.2
# via pydantic
pydot==2.0.0
# via -r requirements-dev.in
pyflakes==3.2.0
# via flake8
pygments==2.17.2
# via pyroma
pyparsing==3.1.1
Expand Down Expand Up @@ -193,6 +172,8 @@ rpds-py==0.18.0
# referencing
rsa==4.7.2
# via awscli
ruff==0.2.2
# via -r requirements-dev.in
s3transfer==0.10.0
# via
# awscli
Expand All @@ -207,7 +188,6 @@ sympy==1.12
# via cfn-lint
tomli==2.0.1
# via
# black
# build
# check-manifest
# mypy
Expand All @@ -232,7 +212,6 @@ types-setuptools==69.0.0.20240125
typing-extensions==4.9.0
# via
# aws-sam-translator
# black
# cattrs
# jsii
# mypy
Expand Down
13 changes: 0 additions & 13 deletions modules/mlflow/mlflow-fargate/setup.cfg

This file was deleted.

12 changes: 6 additions & 6 deletions modules/mlflow/mlflow-fargate/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ def test_rds_settings(stack_defaults):
os.environ["SEEDFARMER_PARAMETER_RDS_HOSTNAME"] = "xxxxx"
os.environ["SEEDFARMER_PARAMETER_RDS_PORT"] = "3306"
os.environ["SEEDFARMER_PARAMETER_RDS_SECURITY_GROUP_ID"] = "sg-12345"
os.environ[
"SEEDFARMER_PARAMETER_RDS_CREDENTIALS_SECRET_ARN"
] = "arn:aws:secretsmanager:us-east-1:111111111111:secret:xxxxxx/xxxxxx-yyyyyy"
os.environ["SEEDFARMER_PARAMETER_RDS_CREDENTIALS_SECRET_ARN"] = (
"arn:aws:secretsmanager:us-east-1:111111111111:secret:xxxxxx/xxxxxx-yyyyyy"
)

import app # noqa: F401


def test_rds_settings_missing_hostname(stack_defaults):
os.environ["SEEDFARMER_PARAMETER_RDS_PORT"] = "3306"
os.environ["SEEDFARMER_PARAMETER_RDS_SECURITY_GROUP_ID"] = "sg-12345"
os.environ[
"SEEDFARMER_PARAMETER_RDS_CREDENTIALS_SECRET_ARN"
] = "arn:aws:secretsmanager:us-east-1:111111111111:secret:xxxxxx/xxxxxx-yyyyyy"
os.environ["SEEDFARMER_PARAMETER_RDS_CREDENTIALS_SECRET_ARN"] = (
"arn:aws:secretsmanager:us-east-1:111111111111:secret:xxxxxx/xxxxxx-yyyyyy"
)

with pytest.raises(ValueError):
import app # noqa: F401
Expand Down
46 changes: 19 additions & 27 deletions modules/mlflow/mlflow-image/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
[tool.black]
[tool.ruff]
exclude = [
".eggs",
".git",
".hg",
".mypy_cache",
".ruff_cache",
".tox",
".venv",
"_build",
"buck-out",
"build",
"dist",
"codeseeder",
]
line-length = 120
target-version = ["py38", "py39", "py310"]
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| \.env
| _build
| buck-out
| build
| dist
| codeseeder.out
)/
'''
target-version = "py38"

[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 120
py_version = 38
skip_gitignore = false
[tool.ruff.lint]
select = ["F", "I", "E", "W"]
fixable = ["ALL"]

[tool.mypy]
python_version = "3.8"
Expand Down
4 changes: 1 addition & 3 deletions modules/mlflow/mlflow-image/requirements-dev.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
awscli
black
cdk-nag
cfn-lint
check-manifest
flake8
isort
mypy
pip-tools
pydot
pyroma
pytest
ruff
types-PyYAML
types-setuptools
Loading

0 comments on commit 1d3f733

Please sign in to comment.