Skip to content

Commit

Permalink
MNT ruff update, remove black (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorentzenchr authored May 18, 2024
1 parent d0e6854 commit fc6ac14
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 211 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:
pip install hatch
- if: matrix.python-version == '3.11' && runner.os == 'Linux'
name: Lint
run: hatch run lint:all
name: Formatter & Linter
run: hatch run format:check

- if: matrix.python-version == '3.11' && runner.os == 'Linux'
name: Build docs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
pip install hatch
- if: matrix.python-version == '3.9' && runner.os == 'Linux'
name: Lint
run: hatch run lint:all
name: Formatter & Linter
run: hatch run format:check

- if: matrix.python-version == '3.9' && runner.os == 'Linux'
name: Build docs
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| CI/CD |[![CI - Test](https://github.com/lorentzenchr/model-diagnostics/actions/workflows/test.yml/badge.svg)](https://github.com/lorentzenchr/model-diagnostics/actions/workflows/test.yml) [![Coverage](https://codecov.io/github/lorentzenchr/model-diagnostics/coverage.svg?branch=main)](https://codecov.io/gh/lorentzenchr/model-diagnostics)
| Docs | [![Docs](https://github.com/lorentzenchr/model-diagnostics/actions/workflows/docs.yml/badge.svg)](https://github.com/lorentzenchr/model-diagnostics/actions/workflows/docs.yml)
| Package | [![PyPI - Version](https://img.shields.io/pypi/v/model-diagnostics.svg?logo=pypi&label=PyPI&logoColor=gold)](https://pypi.org/project/model-diagnostics/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/model-diagnostics.svg?color=blue&label=Downloads&logo=pypi&logoColor=gold)](https://pypi.org/project/model-diagnostics/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/model-diagnostics.svg?logo=python&label=Python&logoColor=gold)](https://pypi.org/project/model-diagnostics/) |
| Meta | [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v0.json)](https://github.com/charliermarsh/ruff) [![code style - black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![types - Mypy](https://img.shields.io/badge/types-Mypy-blue.svg)](https://github.com/python/mypy) [![License - MIT](https://img.shields.io/badge/license-MIT-9400d3.svg)](https://spdx.org/licenses/)
| Meta | [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![types - Mypy](https://img.shields.io/badge/types-Mypy-blue.svg)](https://github.com/python/mypy) [![License - MIT](https://img.shields.io/badge/license-MIT-9400d3.svg)](https://spdx.org/licenses/)

**Tools for diagnostics and assessment of (machine learning) models**

Expand Down
4 changes: 2 additions & 2 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Apart from the default environment are `docs`, `jupyter`, `lint` and `test`

- `hatch run cov` or `hatch run pytest` to run tests
- `hatch -e test run pytest` to run test matrix for multiple versions of python and packages
- `hatch run lint:fmt` to apply `black` and `isort`
- `hatch run lint:all` to check linting, typing, style and security
- `hatch run format:check` to check formatting, linting, typing
- `hatch run format:fix` to apply `ruff format` and `ruff check --fix`
- `hatch run docs:serve` to run a local server under [localhost:8000](localhost:8000)
for the website supporting live updates, i.e. you can change the docs and see
updates immediately. Press Control+C to stop.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| CI/CD |[![CI - Test](https://github.com/lorentzenchr/model-diagnostics/actions/workflows/test.yml/badge.svg)](https://github.com/lorentzenchr/model-diagnostics/actions/workflows/test.yml) [![Coverage](https://codecov.io/github/lorentzenchr/model-diagnostics/coverage.svg?branch=main)](https://codecov.io/gh/lorentzenchr/model-diagnostics)
| Docs | [![Docs](https://github.com/lorentzenchr/model-diagnostics/actions/workflows/docs.yml/badge.svg)](https://github.com/lorentzenchr/model-diagnostics/actions/workflows/docs.yml)
| Package | [![PyPI - Version](https://img.shields.io/pypi/v/model-diagnostics.svg?logo=pypi&label=PyPI&logoColor=gold)](https://pypi.org/project/model-diagnostics/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/model-diagnostics.svg?color=blue&label=Downloads&logo=pypi&logoColor=gold)](https://pypi.org/project/model-diagnostics/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/model-diagnostics.svg?logo=python&label=Python&logoColor=gold)](https://pypi.org/project/model-diagnostics/) |
| Meta | [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v0.json)](https://github.com/charliermarsh/ruff) [![code style - black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![types - Mypy](https://img.shields.io/badge/types-Mypy-blue.svg)](https://github.com/python/mypy) [![License - MIT](https://img.shields.io/badge/license-MIT-9400d3.svg)](https://spdx.org/licenses/)
| Meta | [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![types - Mypy](https://img.shields.io/badge/types-Mypy-blue.svg)](https://github.com/python/mypy) [![License - MIT](https://img.shields.io/badge/license-MIT-9400d3.svg)](https://spdx.org/licenses/)

## Tools for diagnostics and assessment of (machine learning) models

Expand Down
127 changes: 69 additions & 58 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,82 +37,84 @@ dynamic = ["version"]

[tool]

[tool.black]
line-length = 88
target-version = ["py39"]
extend-exclude = ".hatch/*"

[tool.ruff]
line-length = 88
target-version = "py39"
exclude = [".hatch"]
select = [
"A", # flake8-builtins
lint.select = [
"F", # pyflakes
"E", # pycodestyle
"W", # pycodestyle
# "C90", # mccabe
"I", # isort
# "N", # pep8-naming
# "D", # pydocstyle
"UP", # pyupgrade
"YTT", # flake8-2020
# "ANN", # flake8-annotations
# "ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"ASYNC", # flake8-async
"TRIO", # flake8-trio
"S", # flake8-bandit
"BLE", # flake8-blind-except
"C", # flake8-commas
"FBT", # flake8-boolean-trap
"B", # flake8-bugbear
"A", # flake8-builtins
# "COM", # flake8-commas
# "CPY", # flake8-copyright
"C4", # flake8-comprehensions
# "C90", # mccabe
# "D", # pydocstyle
"DJ", # flake8-django
"DTZ", # flake8-datetimez
"E", # pycodestyle
"T10", # flake8-debugger
"DJ", # flake8-django
"EM", # flake8-errmsg
"ERA", # eradicate
"EXE", # flake8-executable
"F", # pyflakes
"FBT", # flake8-boolean-trap
"G", # flake8-logging-format
"I", # isort
# "FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"LOG", # flake8-logging
"G", # flake8-logging-format
# "INP", # flake8-no-pep420
"ISC", # flake8-implicit-str-concat
# "N", # pep8-naming
"NPY", # NumPy-specific rules
"PD", # pandas-vet
# "PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # Pylint
# "PLC", # Pyling Convention
# "PLE", # Pyling Error
# "PLR", # Pyling Refactor
# "PLW", # Pyling Warning
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"T20", # flake8-print
"PYI", # flake8-pyi
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"RSE", # flake8-raise
# "RET", # flake8-return
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLF", # flake8-self
"SLOT", # flake8-slots
"SIM", # flake8-simplify
"T10", # flake8-debugger
"T20", # flake8-print
# "TCH", # flake8-type-checking
"TID", # flake8-tidy-imports
"TCH", # flake8-type-checking
"INT", # flake8-gettext
# "ARG", # flake8-unused-arguments
"PTH", # flake8-use-pathlib
# "TD", # flake8-todos
# "FIX", # flake8-fixme
"ERA", # eradicate
"PD", # pandas-vet
# "PGH", # pygrep-hooks
"PL", # Pylint, subrules "PLC" Convention, "PLE" Error, "PLR" Refactor, "PLW" Warning
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle
"YTT", # flake8-2020
"FLY", # flynt
"NPY", # NumPy-specific rules
"AIR", # Airflow
"PERF", # Perflint
# "FURB", # refurb
"RUF", # Ruff-specific rules
]
ignore = [
lint.ignore = [
"C901",
"ISC001", # recommended to exclude by ruff to avoid conflicts with formatter
"PD901",
"PLR0912",
"PLR0913",
"PLR0915",
"PLR2004",
"ERA001",
]
lint.isort.known-first-party = ["model_diagnostics"]

[tool.ruff.isort]
known-first-party = ["model_diagnostics"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Tests can use assertions, and relative imports
"*/tests/*.py" = ["S101", "TID252"]

Expand Down Expand Up @@ -190,34 +192,43 @@ extra-dependencies = [
[tool.hatch.envs.jupyter.scripts]
lab = "jupyter lab"

[tool.hatch.envs.lint]
[tool.hatch.envs.format]
detached = true
dependencies = [
"black>=22.8.0",
"numpy>=1.22",
"mypy>=1.4",
"ruff==0.0.278",
"ruff==0.4.4",
]

[tool.hatch.envs.lint.scripts]
[tool.hatch.envs.format.scripts]
# typing = "mypy --install-types --non-interactive {args:backend/src/hatchling src/hatch tests}"
typing = [
"python -c 'from pathlib import Path; Path(\".mypy_cache\").mkdir(parents=True, exist_ok=True)'",
"mypy --install-types --non-interactive {args:src/model_diagnostics}"
]
style = [
"ruff {args:.}",
"black --check --diff {args:.}",
format-check = [
"ruff format --check --diff {args:.}",
]
format-fix = [
"ruff format {args:.}",
]
fmt = [
"black {args:.}",
"ruff --fix {args:.}",
"style",
lint-check = [
"ruff check {args:.}",
]
lint-fix = [
"ruff check --fix {args:.}",
]
check = [
"typing",
"format-check",
"lint-check",
]
all = [
"style",
fix = [
"typing",
"format-fix",
"lint-fix",
]
#"ruff check --select I --fix"

[tool.hatch.envs.test]
# We do not want to inherit from envs.default because we explicitely want to have test
Expand Down
6 changes: 3 additions & 3 deletions src/model_diagnostics/calibration/tests/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_plot_reliability_diagram_raises(param, value, msg):
y_obs = [0, 1]
y_pred = [-1, 1]
d = {param: value}
if "functional" not in d.keys():
if "functional" not in d:
d["functional"] = "quantile" # as a default
with pytest.raises(ValueError, match=msg):
plot_reliability_diagram(y_obs=y_obs, y_pred=y_pred, **d)
Expand Down Expand Up @@ -327,9 +327,9 @@ def test_plot_bias(with_null_values, feature_type, confidence_level, ax, plot_ba
feature = (
pl.Series(feature).cast(str).set_at_idx(0, None).cast(dtype)
)
else:
else: # noqa: PLR5501
# FIXME: polars >= 0.19.14
if polars_version >= Version("0.19.14"): # noqa: PLR5501
if polars_version >= Version("0.19.14"):
feature = pl.Series(feature).scatter(0, None)
else:
feature = pl.Series(feature).set_at_idx(0, None)
Expand Down
Loading

0 comments on commit fc6ac14

Please sign in to comment.