Skip to content

Commit

Permalink
that's it, no more flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
chrstnbwnkl committed Jun 4, 2024
1 parent 05a2bf1 commit de91830
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 27 deletions.
21 changes: 11 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
language_version: python3
args: [routing_packager_app, tests]
- repo: https://github.com/pycqa/flake8
rev: 4.0.1 # pick a git hash / tag to point to
hooks:
- id: flake8
- repo: https://github.com/ambv/black
rev: 23.9.1
hooks:
- id: black
language_version: python3
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.289
hooks:
- id: ruff
args: [--fix]
18 changes: 11 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
We :heart: patches, fixes & feature PRs and want to make sure everything goes smoothly for you before and while while submitting a PR.

For development we use:

- [`poetry`](https://github.com/python-poetry/poetry/) as package manager
- `pytest` for testing
- Google's [`yapf`](https://github.com/google/yapf) to make sure the formatting is consistent.
- [`pre-commit`](https://pre-commit.com) hook for yapf
- [`black`](https://github.com/psf/black) to make sure the formatting is consistent.
- [`ruff`](https://github.com/astral-sh/ruff) for linting
- [`pre-commit`](https://pre-commit.com) hook for formatting and linting

When contributing, ideally you:

Expand All @@ -23,11 +25,13 @@ When contributing, ideally you:
1. Create and activate a new virtual environment

2. Install development dependencies:

```bash
poetry install
```

3. Please add a pre-commit hook for `yapf`, so your code gets auto-formatted before committing it:

3. Please add a pre-commit hook, so your code gets auto-formatted and linted before committing it:

```bash
pre-commit install
```
Expand All @@ -39,13 +43,13 @@ You'll need a few things to run the tests:
- PostreSQL installation with a DB named `gis_test` (or define another db name using `POSTGRES_DB_TEST`) **and PostGIS enabled**
- Redis database, best done with `docker run --name redis -p 6379:6379 -d redis:6.0`, then you can use the project's defaults, i.e. `REDIS_URL=redis://localhost:6379/0`
- some fake SMTP service to handle email tests, our recommendations:
- [fake-smtp-server](https://www.npmjs.com/package/fake-smtp-server): NodeJS app with a frontend on `http://localhost:1080` and SMTP port 1025
- pure Python one-liner in a separate terminal window: `sudo python -m smtpd -n -c DebuggingServer localhost:1025`
- [fake-smtp-server](https://www.npmjs.com/package/fake-smtp-server): NodeJS app with a frontend on `http://localhost:1080` and SMTP port 1025
- pure Python one-liner in a separate terminal window: `sudo python -m smtpd -n -c DebuggingServer localhost:1025`

We use `pytest` in this project with `coverage`:

```bash
pytest --cov=routing_packager_app
```
```

A `coverage` bot will report the coverage in every PR and we might ask you to increase coverage on new code.
61 changes: 61 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,64 @@ exclude = '''
| build
)/
'''

[tool.ruff]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["E", "F"]
ignore = []

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"I",
"N",
"Q",
"S",
"T",
"W",
"ANN",
"ARG",
"BLE",
"COM",
"DJ",
"DTZ",
"EM",
"ERA",
"EXE",
"FBT",
"ICN",
"INP",
"ISC",
"NPY",
"PD",
"PGH",
"PIE",
"PL",
"PT",
"PTH",
"PYI",
"RET",
"RSE",
"RUF",
"SIM",
"SLF",
"TCH",
"TID",
"TRY",
"UP",
"YTT",
]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [".venv", "__pycache__", ".git"]

# Same as Black.
line-length = 105
target-version = "py312"
1 change: 0 additions & 1 deletion routing_packager_app/api_v1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class JobCreate(JobBase):


class Job(JobBase, table=True):

__tablename__ = "jobs"

id: Optional[int] = Field(primary_key=True)
Expand Down
2 changes: 1 addition & 1 deletion routing_packager_app/api_v1/routes/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from ...auth.basic_auth import BasicAuth
from ...utils.geom_utils import bbox_to_wkt
from ...utils.file_utils import make_package_path
from ...constants import *
from ...constants import Providers, Statuses

router = APIRouter()

Expand Down
6 changes: 0 additions & 6 deletions setup.cfg

This file was deleted.

4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
from routing_packager_app.worker import create_package
from contextlib import asynccontextmanager


@asynccontextmanager
async def lifespan(app: FastAPI):
pass
pass


@pytest.fixture(scope="session", autouse=True)
def create_worker():
Expand Down
1 change: 0 additions & 1 deletion tests/users/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def test_new_user_unauthorized(get_client, basic_auth_header):


def test_new_user_forbidden(get_client):

response = create_new_user(
get_client,
auth_header={},
Expand Down

0 comments on commit de91830

Please sign in to comment.