8000 Support for PEP 695 - E0001 should not fire on 3.12 generics syntax · Issue #9217 · pylint-dev/pylint · GitHub
[go: up one dir, main page]

Skip to content
Support for PEP 695 - E0001 should not fire on 3.12 generics syntax #9217
@rbobillot

Description

@rbobillot

Current problem

I am using Python 3.12 generics new syntax PEP-695 in a project, such as:

def get_users[I](skip: int | None, limit: int | None, inventory: I) -> list[User]:
    return repo_handler.get_users(skip, limit, inventory)

Unfortunately, pylint cannot parse it and the following error occurs:

repository.py:18:8: E0001: Parsing failed: 'invalid syntax (<unknown>, line 18)' (syntax-error)

I even tried with the basic syntax:

def head[T](args: Iterable[T]) -> T:
    return args[0]

But the same error occurs

Desired solution

For now, I'd say it should give a more ad-hoc error (rather than invalid syntax), so we could at least skip it.
Ideally it should handle this new syntax.

Additional context

I didn't find this issue among pylint open issues.

Though, I found it here in mypy issues
For now, they did a little workaround, saying they cant handle PEP-695 yet,
but it seems that a lot of work needs to be done to handle it.

Unfortunately I'm not sure I have enough free time yet to open a PR and try to fix those issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    InvalidNot a bug, already exists or already fixedpython 3.12

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0