diff --git a/.flake8 b/.flake8 deleted file mode 100644 index f1e3f927..00000000 --- a/.flake8 +++ /dev/null @@ -1,15 +0,0 @@ -[flake8] -ignore = - # whitespace before ':' - doesn't work well with black - E203 - # module level import not at top of file - E402 - # line too long - let black worry about that - E501 - # do not assign a lambda expression, use a def - E731 - # line break before binary operator - W503 -exclude= - .eggs - doc diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ea73c38d..4588d025 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,24 +8,12 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - # isort should run before black as black sometimes tweaks the isort output - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: "v0.2.1" hooks: - - id: isort - # https://github.com/python/black#version-control-integration - - repo: https://github.com/psf/black - rev: 23.12.1 - hooks: - - id: black - - repo: https://github.com/keewis/blackdoc - rev: v0.3.9 - hooks: - - id: blackdoc - - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 - hooks: - - id: flake8 + - id: ruff + args: ["--fix"] # - repo: https://github.com/Carreau/velin # rev: 0.0.8 # hooks: diff --git a/ci/environment.yml b/ci/environment.yml index 876c9a5c..239dea26 100644 --- a/ci/environment.yml +++ b/ci/environment.yml @@ -4,15 +4,14 @@ channels: - nodefaults dependencies: - python>=3.9 - - netcdf4 - - pytest - - flake8 - - black - codecov - - pytest-cov - h5netcdf - kerchunk - - ujson + - netcdf4 - pydantic + - pytest + - pytest-cov + - ruff + - ujson - pip: - git+https://github.com/TomNicholas/xarray.git@concat-no-indexes#egg=xarray diff --git a/pyproject.toml b/pyproject.toml index 159451cf..bf405065 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,13 +65,45 @@ exclude = ["docs", "tests", "tests.*", "docs.*"] [tool.setuptools.package-data] datatree = ["py.typed"] -[tool.isort] -profile = "black" -skip_gitignore = true -float_to_top = true -default_section = "THIRDPARTY" -known_first_party = "virtualizarr" + [mypy] files = "virtualizarr/**/*.py" show_error_codes = true + + + + + +[tool.ruff] +line-length = 100 +target-version = "py39" + +exclude = [ + "docs", + ".eggs"] + + +[tool.ruff.lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E4", "E7", "E9", "F"] +per-file-ignores = {} + +# E402: module level import not at top of file +# E731: do not assign a lambda expression, use a def +# W503: line break before binary operator - not implimeted by ruff due to conflict with PEP8. + +ignore = ["E402", "E731"] + +[tool.ruff.format] +# Indent with spaces, rather than tabs. +indent-style = "space" +# Respect magic trailing commas. +skip-magic-trailing-comma = false +# Automatically detect the appropriate line ending. +line-ending = "auto" + +[tool.ruff.lint.isort] +known-first-party = ["virtualizarr"]