Opened 2 months ago

Closed 7 weeks ago

#36477 closed Cleanup/optimization (fixed)

Add an internal helper for deprecating positional arguments in favor of keyword-only arguments

Reported by: Sarah Boyce Owned by: Mike Edmunds
Component: Utilities Version: dev
Severity: Normal Keywords:
Cc: Mike Edmunds, Adam Johnson Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It is a fairly common pattern that "passing positional arguments [argument names] to [something] is deprecated in favor of keyword-only arguments".
See #34355, #35060 and #36163 for some examples.

As this is common, it would be useful to have a utility to help do this correctly (see #35554 for an issue we have had with this deprecation pathway previously).
It would also be nice to have this utility documented within the deprecation section in the contributing docs: https://docs.djangoproject.com/en/5.2/internals/contributing/writing-code/submitting-patches/#deprecating-a-feature

https://github.com/django/django/pull/19145 implements a decorator to do this

Change History (5)

comment:1 by Natalia Bidart, 2 months ago

Triage Stage: UnreviewedAccepted

comment:2 by Natalia Bidart, 2 months ago

Needs tests: set
Patch needs improvement: set

comment:3 by Mike Edmunds, 2 months ago

Needs tests: unset
Patch needs improvement: unset

comment:4 by Natalia Bidart, 7 weeks ago

Triage Stage: AcceptedReady for checkin

comment:5 by GitHub <noreply@…>, 7 weeks ago

Resolution: fixed
Status: assignedclosed

In f42b89f:

Fixed #36477, Refs #36163 -- Added @deprecate_posargs decorator to simplify deprecation of positional arguments.

This helper allows marking positional-or-keyword parameters as keyword-only with a deprecation period, in a consistent and correct manner.

Note: See TracTickets for help on using tickets.
Back to Top