Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

typing tests: Not all subclass cases are covered #96769

Copy link
Copy link
@sobolevn

Description

@sobolevn
Issue body actions

There are a lot of test cases in test_typing.py where we test that different typing things cannot be used as base classes. However, there are multiple missing cases. Examples:

  • Final / Final[int] is not tested to be invalid base class:
    def test_cannot_subclass(self):
    with self.assertRaisesRegex(TypeError, CANNOT_SUBCLASS_TYPE):
    class C(type(Final)):
    pass
    with self.assertRaisesRegex(TypeError, CANNOT_SUBCLASS_TYPE):
    class C(type(Final[int])):
    pass
    def test_cannot_init(self):
  • Ts is tested, but *Ts is not:
    class C(Ts): pass
  • Different special forms only tested with / or without []
  • And other issues

I think this should be all covered. I went through all subtyping tests and added more cases.
I will send a PR :)

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirTests in the Lib/test dirtopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.