Skip to content

Missing type annotation for FILTERS #2120

@Gabgobie

Description

@Gabgobie

When using Jinja2 with filters, Pylance is screaming at me because Environment.filters is partially unknown.

Environment.filters is copied from here:

FILTERS = {

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions