When using Jinja2 with filters, Pylance is screaming at me because Environment.filters is partially unknown.
Environment.filters is copied from here:
FILTERS does not have a type annotation.
You already defined a TypeVar for the expected signature here:
|
F = t.TypeVar("F", bound=t.Callable[..., t.Any]) |
Is there a specific reason to leave out the annotation? I'd be happy to submit a PR.
# Suggested code
FILTERS: dict[str, F] = {
Best,
Gab
Environment:
- Python version: 3.12
- Jinja version: 3.1.6
- I searched for other issues with the keywords
type and filter
- I tested the suggested changes locally by modifying jinja in my venv
When using Jinja2 with filters, Pylance is screaming at me because
Environment.filtersis partially unknown.Environment.filters is copied from here:
jinja/src/jinja2/filters.py
Line 1812 in 5ef7011
FILTERSdoes not have a type annotation.You already defined a TypeVar for the expected signature here:
jinja/src/jinja2/filters.py
Line 44 in 5ef7011
Is there a specific reason to leave out the annotation? I'd be happy to submit a PR.
Best,
Gab
Environment:
typeandfilter