Skip to content

from __future__ import annotations as <identifier> not supported #3798

Closed
@analog-cbarber

Description

@analog-cbarber

In pylint 2.6.0 (and earlier) under python 3.7, the following produces an incorrect warning for
the '-> C:' return value.

from __future__ import annotations as __annotations__

class C:
    @classmethod
    def create(cls) -> C: # bogus warning: Undefined variable 'C'
        return cls()

There is no warning when the as clause is not there.

This clause is required in some spaces in order to avoid having the annotations symbol pollute the
namespace and is not supposed to affect the processing future clause.

See https://docs.python.org/3/reference/simple_stmts.html#future

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions