Skip to content

Commit

Permalink
Switch to ruff (#543)
Browse files Browse the repository at this point in the history
Co-authored-by: Wei Ji <[email protected]>
  • Loading branch information
mfisher87 and weiji14 authored Aug 12, 2024
1 parent 49501ec commit e0e1738
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 81 deletions.
37 changes: 0 additions & 37 deletions .flake8

This file was deleted.

13 changes: 7 additions & 6 deletions .github/workflows/linter_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run black linter
uses: psf/black@stable
# use the flake8 linter to annotate improperly formatted code
# note linter arguments are supplied via the .flake8 config file
- name: Annotate PR after running flake8
uses: TrueBrain/actions-flake8@v2

# Use the Ruff linter to annotate code style / best-practice issues
# NOTE: More config provided in pyproject.toml
- name: Lint and annotate PR
uses: chartboost/ruff-action@v1
with:
args: "check . --output-format github"
30 changes: 16 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
repos:
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-toml
- id: check-yaml
- id: check-added-large-files
args: ["--maxkb=5000"]
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0 # Use the ref you want to point at
hooks:
- id: check-toml
- id: check-yaml
- id: check-added-large-files
args: ["--maxkb=5000"]
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

ci:
autoupdate_schedule: monthly
Expand Down
1 change: 1 addition & 0 deletions doc/sphinxext/announce.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
$ ./scripts/announce.py $GITHUB v1.11.0..v1.11.1 > announce.rst
"""

import codecs
import os
import re
Expand Down
19 changes: 11 additions & 8 deletions icepyx/core/is2ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ def _validate_OA_product(product):
"""
if isinstance(product, str):
product = str.upper(product)
assert product in [
"ATL06",
"ATL07",
"ATL08",
"ATL10",
"ATL12",
"ATL13",
], "Oops! Elevation visualization only supports products ATL06, ATL07, ATL08, ATL10, ATL12, ATL13; please try another product."
assert (
product
in [
"ATL06",
"ATL07",
"ATL08",
"ATL10",
"ATL12",
"ATL13",
]
), "Oops! Elevation visualization only supports products ATL06, ATL07, ATL08, ATL10, ATL12, ATL13; please try another product."
else:
raise TypeError("Please enter a product string")
return product
Expand Down
1 change: 1 addition & 0 deletions icepyx/tests/test_Earthdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
test icepyx.core.query.Query.earthdata_login function
"""

import netrc
import os
import pytest
Expand Down
65 changes: 51 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ maintainers = [
]

classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: GIS",
"Topic :: Software Development :: Libraries",
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: GIS",
"Topic :: Software Development :: Libraries",
]

[project.urls]
Expand Down Expand Up @@ -61,3 +61,40 @@ version_file = "_icepyx_version.py"
version_file_template = 'version = "{version}"'
local_scheme = "node-and-date"
fallback_version = "unknown"
# [tool.ruff.format]
# docstring-code-format = true
# docstring-code-line-length = "dynamic"

[tool.ruff.lint]
select = [
"E", # pycodestyle
"F", # pyflakes
]
ignore = [
# Line too long
# NOTE: This is a formatting concern. Formatter handles long lines of code,
# but allows inline comments to be infinitely long (automatically formatting
# them can have unintended consequences). In our codebase, we have a lot of
# overlong comments.
# See: https://github.com/psf/black/issues/1713#issuecomment-1357045092
"E501",
# TODO: remove ignores below this line
# comparison syntax in tests
"E721",
# bare except
"E722",
# unable to detect undefined names
"F403",
]

[tool.ruff.lint.per-file-ignores]
# Ignore import violations in all `__init__.py` files and doc config
"__init__.py" = ["E402", "F401"]
"doc/source/conf.py" = ["E402", "F401"]

# Ignore line length in test file containing some very long test strings
"test_granules.py" = ["E501"]
"test_spatial.py" = ["E501"]

# Ignore too many leading '#' for block comment
"*/tests/*" = ["E266"]
2 changes: 0 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
black
flake8
pre-commit
pypistats
pytest>=4.6
Expand Down

0 comments on commit e0e1738

Please sign in to comment.