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

Support 202408 #105

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
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
28 changes: 4 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,20 @@ exclude: |
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.11
rev: v0.6.5
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
Expand All @@ -33,17 +27,3 @@ repos:
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,4 @@
- cascade delete for relational tables
- fixed foreign key related names
### Removed
- poc list tests
- poc list tests
2 changes: 1 addition & 1 deletion Ctl/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.0
3.4.0
2 changes: 1 addition & 1 deletion Ctl/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ ctl:
type: version
permissions:
- namespace: "ctl"
permission: "r"
permission: "r"
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
Django models for PeeringDB

See the docs at http://peeringdb.github.io/django-peeringdb/

1 change: 0 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,3 @@ Only sync these tables
python manage.py pdb_sync

Will sync the full peeringdb database to your models, any subsequent call will only sync records that have changed.

1 change: 0 additions & 1 deletion docs/sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ peeringdb sync
```

## Common problems

1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ pages:
- Home: 'index.md'

markdown_extensions: [abbr,def_list,footnotes,tables,admonition,nl2br,toc]

1,293 changes: 661 additions & 632 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Internet",
]
Expand All @@ -41,9 +42,6 @@ pytest-cov = "*"
tox = ">=3.24"

# linting
black = ">=20"
isort = ">=5.7"
flake8 = ">=3.8"
mypy = ">=0.950"
pre-commit = ">=2.13"
pyupgrade = ">=2.19"
Expand All @@ -63,10 +61,9 @@ twine = ">=3.3"
[tool.poetry.plugins."markdown.extensions"]
pymdgen = "pymdgen.md:Extension"


[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
profile = "black"
Expand Down
1 change: 0 additions & 1 deletion src/django_peeringdb/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class MultipleChoiceField(models.CharField):

"""
Field that can take a set of string values
and store them in a charfield using a delimiter
Expand Down
61 changes: 61 additions & 0 deletions src/django_peeringdb/migrations/0034_fix_voltage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Generated by Django 4.2.7 on 2024-08-07 19:37

from django.db import migrations


def _from_db_value(value, expression, connection):
# for bypass clean_choices validation
if value is None:
return None
if not value or value == "[]":
return []
return value.split(",")

Check warning on line 12 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#L8-L12

Added lines #L8 - L12 were not covered by tests


def forward(apps, schema_editor):
Facility = apps.get_model("django_peeringdb", "Facility")
updated_field = Facility._meta.get_field("updated")
updated_field_auto_now = updated_field.auto_now
from_db_value = Facility._meta.get_field("available_voltage_services").from_db_value
invalid_voltage_values = ["120 VAC", "208 VAC", "240 VAC"]

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
facilities = Facility.handleref.all()
for facility in facilities:
voltage = facility.available_voltage_services
removed = []

Check warning on line 31 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#L30-L31

Added lines #L30 - L31 were not covered by tests

for invalid_voltage_value in invalid_voltage_values:
try:
voltage.remove(invalid_voltage_value)
removed.append(invalid_voltage_value)
except ValueError:
pass

Check warning on line 38 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#L33-L38

Added lines #L33 - L38 were not covered by tests

if removed:
facility.available_voltage_services = voltage
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
updated_field.auto_now = updated_field_auto_now


class Migration(migrations.Migration):
dependencies = [
(
"django_peeringdb",
"0033_alter_facility_property_alter_ixlan_rs_asn_and_more",
),
]

operations = [
migrations.RunPython(forward, migrations.RunPython.noop),
]
Loading