Skip to content

Distinguish rate limits for same-named class methods - #305

Open
ghdtjdwn wants to merge 1 commit into
laurentS:masterfrom
ghdtjdwn:fix/173-qualified-route-names
Open

ghdtjdwn wants to merge 1 commit into
laurentS:masterfrom
ghdtjdwn:fix/173-qualified-route-names

Conversation

@ghdtjdwn

@ghdtjdwn ghdtjdwn commented Sep 7, 2026

Copy link
Copy Markdown

Rate-limit registration and lookup currently identify endpoints using their module and __name__, so methods such as First.index and Second.index share configuration. This can apply limits twice or allow one route's exemption to bypass another route's limit.

Use __qualname__ consistently for registration, lookup, exemptions, and middleware matching. Add regression tests for synchronous and asynchronous endpoints, static and dynamic limits, both key styles, exemptions, and default limits.

With key_style="endpoint", class methods and nested functions receive new storage keys, so existing counters are not carried over. Module-level functions and URL-based keys keep their existing keys. This behavior is documented in the examples.

Validation on Python 3.11 using the existing lock file: all 18 regression cases fail before the fix and pass afterward; all 121 tests pass after the fix. Black, mypy, and flake8 F401 pass. Documentation builds with MkDocs strict in a separate environment using compatible Markdown/importlib-metadata versions; the lock-file documentation environment fails during import on Python 3.11.

Fixes #173.

@ghdtjdwn

Copy link
Copy Markdown
Author

The Python package workflow is waiting for approval. Could a maintainer approve the run and review the qualified route-name change for #173 when convenient? The PR description includes the regression coverage and the compatibility note about endpoint-based storage keys for class methods and nested functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The limiters of different routes with the same function name are confused, resulting in multiple checks

1 participant