Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
vegu committed Oct 7, 2024
1 parent 1ad9fc0 commit 520dee5
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 39 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:
uses: 20c/workflows/poetry@v1
- name: Run linters
run: |
poetry run isort src/
poetry run black --check src/
poetry run pre-commit run --all-files
test:
Expand Down
25 changes: 2 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,14 @@ repos:
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
args: ["--select", "I", "--fix"]
# Run the formatter.
- id: ruff-format
- repo: local
hooks:
- id: system
name: isort
entry: poetry run isort .
language: system
pass_filenames: false
- repo: local
hooks:
- id: pyupgrade
name: pyupgrade
entry: poetry run pyupgrade --py38-plus
language: python
types: [python]
pass_filenames: true
- repo: local
hooks:
- id: system
name: Black
entry: poetry run black .
language: system
pass_filenames: false
- repo: local
hooks:
- id: system
name: flake8
entry: poetry run flake8 .
language: system
pass_filenames: false
pass_filenames: true
12 changes: 6 additions & 6 deletions src/django_peeringdb/migrations/0034_fix_voltage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def forward(apps, schema_editor):
try:
# overide from_db_value method
# because this method calls "clean_choices" resulting in a validation error when retrieving all facilites.
Facility._meta.get_field("available_voltage_services").from_db_value = (
_from_db_value
)
Facility._meta.get_field(
"available_voltage_services"
).from_db_value = _from_db_value
facilities = Facility.handleref.all()
for facility in facilities:
voltage = facility.available_voltage_services
Expand All @@ -42,9 +42,9 @@ def forward(apps, schema_editor):
print(f"Removed {removed} from {facility}")
facility.save()

Check warning on line 43 in src/django_peeringdb/migrations/0034_fix_voltage.py

View check run for this annotation

Codecov / codecov/patch

src/django_peeringdb/migrations/0034_fix_voltage.py#L40-L43

Added lines #L40 - L43 were not covered by tests
finally:
Facility._meta.get_field("available_voltage_services").from_db_value = (
from_db_value
)
Facility._meta.get_field(
"available_voltage_services"
).from_db_value = from_db_value
updated_field.auto_now = updated_field_auto_now


Expand Down
1 change: 0 additions & 1 deletion tests/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.db import models

from django_peeringdb.models import LG_URLField, MultipleChoiceField, URLField


Expand Down
5 changes: 2 additions & 3 deletions tests/test_client_adaptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
from decimal import Decimal

import django.core.exceptions
import django_peeringdb.models as models
import pytest
from django.db import IntegrityError
from django.db.transaction import atomic as atomic_transaction

import django_peeringdb.models as models
from django_peeringdb.client_adaptor.load import database_settings

# import order is important here, linters will complain
# about the backend import not being on top of the file
# TODO: find better way to handle this
import tests.peeringdb_mock # noqa
from django_peeringdb.client_adaptor.load import database_settings

sys.modules["peeringdb"] = sys.modules["tests.peeringdb_mock"] # noqa
from django_peeringdb.client_adaptor.backend import Backend # noqa
Expand Down
1 change: 0 additions & 1 deletion tests/test_concrete_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest

from django_peeringdb.models import Carrier, CarrierFacility, Facility, Organization


Expand Down
3 changes: 1 addition & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.test import TestCase

import django_peeringdb.models
from django.test import TestCase


class CoreTests(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest
from django.core.exceptions import ValidationError
from django.test import TestCase

from django_peeringdb.models import LG_URLField, URLField

from tests.models import FieldModel, LG_FieldModel


Expand Down

0 comments on commit 520dee5

Please sign in to comment.