However, the
[https://github.com/django/django/blob/551c997feaaa293987af8b05efc3634b93305fac/django/forms/forms.py#L54
`BaseForm`] does not have a class level initialisation of these. The
classes are then later added via a `hasattr` check.
I was wondering if class level defaults (`None`) should be added for these
to make them more discovarable, also the `hasattr` logic can just be
replaced with `Form.required_css_class`
--
Ticket URL: <https://code.djangoproject.com/ticket/33226>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => duplicate
Comment:
Hey David, this is a duplicate of #14322.
''Possibly'' that's worth re-opening (via a discussion,
[https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
tickets/#closing-tickets following triage guidelines for wontfix tickets])
— auto-complete and type checkers much prefer attributes to be defined (as
`None`?) rather than injected later.
I recall we've closed similar proposals along these lines though; often
the references are able to remain entirely within the injecting code,
whereas if they're declared (suddenly) they're split over multiple files.
(e.g. excluding usages, `required_css_class` appears **only** in
`boundfield.py`) — we didn't want to litter class definitions and/or init
methods with `None` declarations. (Better the tooling gets cleverer.)
Also #14322 (and #3512) were concerned about backwards compatibility. The
specific issue there may not apply after all this time, but it needs a
thought.
--
Ticket URL: <https://code.djangoproject.com/ticket/33226#comment:1>