[PR #20533] [MERGED] Closes #20527: Address deprecation warnings #15957

Closed
opened 2025-12-30 00:25:01 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/20533
Author: @pheus
Created: 10/8/2025
Status: Merged
Merged: 10/9/2025
Merged by: @jnovinger

Base: mainHead: 20527-address-deprecation-warnings


📝 Commits (6)

  • 93f7f5a fix(dcim): Correct accessor for u_height in device tables
  • f831a1a fix(extra): Replace deprecated 'ordering='
  • 12af776 fix(core): Fix import path for ObjectChangeType in mixins
  • 85d4570 fix(graphql): Add explicit type annotations for Info parameter
  • 4cf19c1 fix(graphql): Update filter method prefix to use DirectiveValue
  • 83d423e fix(forms): Opt URLField into https default on contact forms

📊 Changes

9 files changed (+39 additions, -23 deletions)

View changed files

📝 netbox/core/graphql/mixins.py (+5 -5)
📝 netbox/dcim/graphql/gfk_mixins.py (+5 -3)
📝 netbox/dcim/tables/devices.py (+1 -1)
📝 netbox/extras/graphql/mixins.py (+5 -4)
📝 netbox/extras/querysets.py (+1 -1)
📝 netbox/netbox/graphql/filter_lookups.py (+5 -4)
📝 netbox/netbox/graphql/types.py (+2 -1)
📝 netbox/tenancy/forms/bulk_import.py (+10 -4)
📝 netbox/tenancy/forms/model_forms.py (+5 -0)

📄 Description

Fixes: #20527

This PR removes the warnings reported in #20527 by updating form fields, GraphQL resolvers, table accessors, and PostgreSQL aggregates to their current, forward‑compatible APIs. It also consolidates a GraphQL import path for clarity.

None of the changes alter user‑visible behavior; they silence deprecations and improve typing so we’re ready for Django 6.0, Strawberry ≥1.0, and django‑tables2 v3.


What’s changed

Forms (URLField default scheme)

  • Contact import & model forms: Opt into the HTTPS default by adding assume_scheme='https' to:
    • ContactImportForm.link
    • ContactForm.link
  • Rationale: Django 6.0 changes the default URL scheme to HTTPS. Passing assume_scheme='https' silences RemovedInDjango60Warning during form construction.

Optional backstop (not included in this PR): set FORMS_URLFIELD_ASSUME_HTTPS = True in settings to adopt the future default globally during the Django 5.x window.

GraphQL (Strawberry)

  • Annotate reserved args: Replace untyped info parameters with info: Info across GraphQL mixins and types to remove the

    “argument name‑based matching of info is deprecated”
    warning and align with Strawberry’s typing rules.

  • Directive typing: Where a filter method uses a prefix directive, annotate as prefix: DirectiveValue[str] for correctness.
  • Import path tidy‑up: Consolidate the import for ObjectChangeType under core.graphql.types to keep type hints consistent.

Tables (django-tables2)

  • Accessor separator: Update DeviceTable to use device_type__u_height instead of device_type.u_height to comply with django_tables2’s __ accessor convention and remove the deprecation.

Querysets (PostgreSQL aggregates)

  • Kwarg rename: Replace deprecated ordering= with order_by= on EmptyGroupByJSONBAgg(...) to match Django 5.2+.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/20533 **Author:** [@pheus](https://github.com/pheus) **Created:** 10/8/2025 **Status:** ✅ Merged **Merged:** 10/9/2025 **Merged by:** [@jnovinger](https://github.com/jnovinger) **Base:** `main` ← **Head:** `20527-address-deprecation-warnings` --- ### 📝 Commits (6) - [`93f7f5a`](https://github.com/netbox-community/netbox/commit/93f7f5a595a6ff3e97cd9f63ed867109a739b159) fix(dcim): Correct accessor for u_height in device tables - [`f831a1a`](https://github.com/netbox-community/netbox/commit/f831a1ae1b4c756285dbafe9c829275c412f981a) fix(extra): Replace deprecated 'ordering=' - [`12af776`](https://github.com/netbox-community/netbox/commit/12af7761b1d748790f4524fc57f5a36df324d185) fix(core): Fix import path for ObjectChangeType in mixins - [`85d4570`](https://github.com/netbox-community/netbox/commit/85d4570758e76f9f6eda48b30daecbe19c1a80a1) fix(graphql): Add explicit type annotations for `Info` parameter - [`4cf19c1`](https://github.com/netbox-community/netbox/commit/4cf19c1975c2cab4272f88c7095765469abd2fe5) fix(graphql): Update filter method prefix to use DirectiveValue - [`83d423e`](https://github.com/netbox-community/netbox/commit/83d423efef12024f40d15bcef6346743dc151686) fix(forms): Opt URLField into https default on contact forms ### 📊 Changes **9 files changed** (+39 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `netbox/core/graphql/mixins.py` (+5 -5) 📝 `netbox/dcim/graphql/gfk_mixins.py` (+5 -3) 📝 `netbox/dcim/tables/devices.py` (+1 -1) 📝 `netbox/extras/graphql/mixins.py` (+5 -4) 📝 `netbox/extras/querysets.py` (+1 -1) 📝 `netbox/netbox/graphql/filter_lookups.py` (+5 -4) 📝 `netbox/netbox/graphql/types.py` (+2 -1) 📝 `netbox/tenancy/forms/bulk_import.py` (+10 -4) 📝 `netbox/tenancy/forms/model_forms.py` (+5 -0) </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be approved and assigned prior to opening a pull request. This helps avoid waste time and effort on a proposed change that we might not be able to accept. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED TO YOU, IT WILL BE CLOSED AUTOMATICALLY. Please specify your assigned issue number on the line below. --> ### Fixes: #20527 This PR removes the warnings reported in #20527 by updating form fields, GraphQL resolvers, table accessors, and PostgreSQL aggregates to their current, forward‑compatible APIs. It also consolidates a GraphQL import path for clarity. None of the changes alter user‑visible behavior; they silence deprecations and improve typing so we’re ready for Django 6.0, Strawberry ≥1.0, and django‑tables2 v3. --- ### What’s changed #### Forms (URLField default scheme) - **Contact import & model forms:** Opt into the HTTPS default by adding `assume_scheme='https'` to: - `ContactImportForm.link` - `ContactForm.link` - Rationale: Django 6.0 changes the default URL scheme to HTTPS. Passing `assume_scheme='https'` silences `RemovedInDjango60Warning` during form construction. > _Optional backstop (not included in this PR):_ set `FORMS_URLFIELD_ASSUME_HTTPS = True` in settings to adopt the future default globally during the Django 5.x window. #### GraphQL (Strawberry) - **Annotate reserved args:** Replace untyped `info` parameters with `info: Info` across GraphQL mixins and types to remove the > “argument name‑based matching of `info` is deprecated” warning and align with Strawberry’s typing rules. - **Directive typing:** Where a filter method uses a `prefix` directive, annotate as `prefix: DirectiveValue[str]` for correctness. - **Import path tidy‑up:** Consolidate the import for `ObjectChangeType` under `core.graphql.types` to keep type hints consistent. #### Tables (django-tables2) - **Accessor separator:** Update `DeviceTable` to use `device_type__u_height` instead of `device_type.u_height` to comply with `django_tables2`’s `__` accessor convention and remove the deprecation. #### Querysets (PostgreSQL aggregates) - **Kwarg rename:** Replace deprecated `ordering=` with `order_by=` on `EmptyGroupByJSONBAgg(...)` to match Django 5.2+. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:25:01 +01:00
adam closed this issue 2025-12-30 00:25:01 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15957