Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace flake8 and isort with ruff #101

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,4 @@ jobs:
name: Black
command: |
. ~/venv/bin/activate
make black
- run:
name: iSort
command: |
. ~/venv/bin/activate
make isort
make black_check
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import django


sys.path.insert(0, os.path.abspath("..")) # for discovery of project modules
sys.path.insert(0, os.path.abspath(".")) # for discovery of doc_settings.py

Expand Down
22 changes: 13 additions & 9 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,27 @@ clean:
# Static analysis

lint:
flake8
make black_check ruff mypy

test:
py.test
black_check:
black --check --diff .

black:
black -v --check .

isort:
isort --check-only .
ruff:
ruff check .

mypy:
mypy

test:
py.test

format:
ruff check --fix .
black .

docker_images:
docker build -t xocto/pytest --target=pytest .
docker build -t xocto/isort --target=isort .
docker build -t xocto/ruff --target=ruff .
docker build -t xocto/black --target=black .

# Releases
Expand Down
43 changes: 35 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
[tool.black]
line-length = 99

[tool.isort]
multi_line_output = 3
include_trailing_comma = "True"
force_grid_wrap = 0
use_parentheses = "True"
line_length = 99
skip_glob = "venv/*"

[tool.mypy]
# Specify which files to check.
files = [
Expand Down Expand Up @@ -74,3 +66,38 @@ module = [
"zoneinfo.*",
]
ignore_missing_imports = true


# Ruff
# ----

[tool.ruff]
select = [
"E", # pycodestyle
"F", # pyflakes
"I", # isort
]
ignore = [
"E501", # line too long - black takes care of this for us
]

[tool.ruff.per-file-ignores]
# Allow unused imports in __init__ files as these are convenience imports
"**/__init__.py" = [ "F401" ]

[tool.ruff.isort]
lines-after-imports = 2
section-order = [
"future",
"standard-library",
"third-party",
"first-party",
"project",
"local-folder",
]

[tool.ruff.isort.sections]
"project" = [
"xocto",
"tests",
]
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from setuptools import setup


REPO_ROOT = path.abspath(path.dirname(__file__))

VERSION = "4.3.0"
Expand Down Expand Up @@ -51,12 +52,12 @@
"black==22.12.0",
"boto3==1.26.53",
"botocore==1.29.53",
"isort==5.11.4",
"mypy-boto3-s3==1.26.0.post1",
"mypy==0.991",
"numpy==1.22.2",
"pre-commit>=3.2.0",
"pyarrow-stubs==10.0.1.6",
"ruff==0.0.292",
"twine==4.0.2",
"types-openpyxl==3.0.4.5",
"types-python-dateutil==2.8.19.6",
Expand All @@ -65,7 +66,7 @@
"wheel==0.38.4",
],
"test": [
"flake8==6.0.0",
"ruff==0.0.292",
"hypothesis==6.62.1",
"moto[s3,sqs]==4.1",
"pytest-django==4.5.2",
Expand Down
1 change: 1 addition & 0 deletions tests/storage/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from tests.storage.helpers import fixtures as fixture_helpers


# Fixture (as in files used in testing) loading


Expand Down
2 changes: 1 addition & 1 deletion tests/test_localtime.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import datetime
import decimal
import zoneinfo

import pytest
import time_machine
import zoneinfo
from dateutil import relativedelta
from django.conf import settings
from django.test import override_settings
Expand Down
1 change: 1 addition & 0 deletions tests/test_settlement_periods.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from xocto import settlement_periods


UTC_TZ = datetime.timezone.utc
GB_TZ = pytz.timezone("Europe/London")

Expand Down
1 change: 1 addition & 0 deletions xocto/events/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django import http
from django.conf import settings


logger = structlog.get_logger("events")

__all__ = ["publish"]
Expand Down
1 change: 1 addition & 0 deletions xocto/events/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time
from typing import Any


__all__ = ["Timer"]


Expand Down
Loading