Skip to content

For extending the type alias created with TypeAlias or an assignment statement, pyrefly should also give error for consistency #2002

@hyperkai

Description

@hyperkai

Describe the Bug

Memo:

  • pyrefly check
  • pyrefly 0.46.1
  • Python 3.14.0

Extending the type alias created with a type statement or TypeAliasType, pyrefly gives the error as shown below:

''' Type statement '''
type TA = int
''' Type statement '''

''' TypeAliasType '''
# from typing import TypeAliasType

# TA = TypeAliasType('TA', value=int)
''' TypeAliasType '''

class Cls(TA): pass # Error

ERROR Cannot use scoped type alias TA as a base class. Use a legacy type alias instead: TA: TypeAlias = type[int]

But extending the type alias created with TypeAlias or an assignment statement, pyrefly doesn't give error as shown below so error should also occur for consistency:

''' TypeAlias '''
from typing import TypeAlias

TA: TypeAlias = int
''' TypeAlias '''

''' Assignment statement '''
# TA = int
''' Assignment statement '''

class Cls(TA): pass # No error

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-discussionAn issue where it's not clear whether there is a bug or we are behaving as expected.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions