Skip to content

Base class attribute type does not provide type context in subclass #4547

Closed
@JukkaL

Description

@JukkaL

In this example there is an unnecessary message about needing a type annotation:

from typing import List

class A:
    x: List[str]

class B(A):
    x = []  # Need type annotation

Here we should we able to use the base class type for x as type context for the x initializer.

This is closely related to #3208.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions