werkzeug icon indicating copy to clipboard operation
werkzeug copied to clipboard

`Rule.endpoint` type annotation doesn't comply with the documentation

Open jkhsjdhjs opened this issue 2 years ago • 0 comments

According to the documentation, anything can be used as a Rule endpoint: https://werkzeug.palletsprojects.com/en/3.0.x/routing/#werkzeug.routing.Rule

The endpoint for this rule. This can be anything. A reference to a function, a string, a number etc. The preferred way is using a string because the endpoint is used for URL generation.

However, the type is annotated as str | None: https://github.com/pallets/werkzeug/blob/d3dd65a27388fbd39d146caacf2563639ba622f0/src/werkzeug/routing/rules.py#L448 https://github.com/pallets/werkzeug/blob/d3dd65a27388fbd39d146caacf2563639ba622f0/src/werkzeug/routing/rules.py#L488

The same applies to the parameter endpoint of MapAdapter.build() (and possibly more): https://github.com/pallets/werkzeug/blob/d3dd65a27388fbd39d146caacf2563639ba622f0/src/werkzeug/routing/map.py#L825

Environment:

  • Werkzeug version: 3.0.1

jkhsjdhjs avatar Jan 12 '24 22:01 jkhsjdhjs