Closes #20527: Address deprecation warnings #1101

Closed
opened 2026-04-05 20:39:47 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @pheus on 10/8/2025

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+.
*Originally created by @pheus on 10/8/2025* <!-- 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+.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#1101