Skip to content

Commit

Permalink
Switch from flake8 to ruff, reformat all missing files (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrgn authored Nov 3, 2024
1 parent 9ce09af commit b334b15
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 30 deletions.
6 changes: 3 additions & 3 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from config import views

urlpatterns = [
re_path(r'^admin/', admin.site.urls),
re_path(r'^api/v1/', include(reservation_urls)),
re_path(r'^healthcheck/', views.healthcheck),
re_path(r"^admin/", admin.site.urls),
re_path(r"^api/v1/", include(reservation_urls)),
re_path(r"^healthcheck/", views.healthcheck),
]
4 changes: 2 additions & 2 deletions config/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ def healthcheck(request):
cursor.execute("SELECT count(*) FROM django_migrations")
count = cursor.fetchone()[0]
if count > 0:
return JsonResponse({'db': 'ok'}, status=200)
return JsonResponse({"db": "ok"}, status=200)
else:
return JsonResponse({'db': 'error, no migrations applied'}, status=500)
return JsonResponse({"db": "error, no migrations applied"}, status=500)
18 changes: 9 additions & 9 deletions docker/healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import http.client
import os

HOST = '127.0.0.1'
HOST = "127.0.0.1"
PORT = 8000

if __name__ == '__main__':
hostname = os.environ.get('ALLOWED_HOST', 'localhost')
conn = http.client.HTTPConnection(f'{HOST}:{PORT}')
conn.request('GET', '/healthcheck/', headers={'host': hostname})
if __name__ == "__main__":
hostname = os.environ.get("ALLOWED_HOST", "localhost")
conn = http.client.HTTPConnection(f"{HOST}:{PORT}")
conn.request("GET", "/healthcheck/", headers={"host": hostname})
response = conn.getresponse()
print(f'HTTP {response.status} {response.reason}')
body = response.read().decode('utf8')
print(f'Body: {body}')
assert response.status == 200, 'Non-200 response'
print(f"HTTP {response.status} {response.reason}")
body = response.read().decode("utf8")
print(f"Body: {body}")
assert response.status == 200, "Non-200 response"
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[tool.ruff]
exclude = [
"setup.py",
"migrations",
]
line-length = 99
3 changes: 1 addition & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
-r requirements.txt
pytest~=6.2
pytest-django~=4.4
flake8<4 # https://github.com/tholo/pytest-flake8/issues/81
pytest-flake8~=1.0.7
pytest-cov~=3.0
pytest-ruff~=0.4.1
model-bakery~=1.3
8 changes: 2 additions & 6 deletions reservations/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
# Regular overlaps
(baker.prepare(models.Reservation, start=now, end=now + delta * 2), True),
(
baker.prepare(
models.Reservation, start=now - delta / 2, end=now + delta / 2
),
baker.prepare(models.Reservation, start=now - delta / 2, end=now + delta / 2),
True,
),
(baker.prepare(models.Reservation, start=now - delta * 2, end=now), True),
Expand All @@ -31,9 +29,7 @@
(baker.prepare(models.Reservation, start=now - delta, end=now + delta), True),
# Non conflicts
(
baker.prepare(
models.Reservation, start=now - delta * 3, end=now - delta * 2
),
baker.prepare(models.Reservation, start=now - delta * 3, end=now - delta * 2),
False,
),
(
Expand Down
9 changes: 1 addition & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
[tool:pytest]
DJANGO_SETTINGS_MODULE = config.settings
addopts = --cov reservations --cov-config .coveragerc --flake8 --tb=short
addopts = --cov reservations --cov-config .coveragerc --ruff --ruff-format --tb=short
python_files = test_*.py
flake8-max-line-length = 99
flake8-ignore =
*.py E126 E127 E128
setup.py ALL
settings.py ALL
*/migrations/* ALL
*/tests/* ALL

0 comments on commit b334b15

Please sign in to comment.