Skip to content

stubtest: Abstract properties are not detected #13646

Closed

Description

@sobolevn

Code:

from abc import abstractmethod

class Some:
    @property
    @abstractmethod
    def x(self) -> int:
         return 1

Stub:

class Some:
    @property
    def x(self) -> int: ...

No errors are shown.
It should raise an error about abstract state mismatch.
Realted python/typeshed#8726

Activity

  1. AlexWaygood commented on Sep 11, 2022

    @AlexWaygood
    Member

    I thought you already fixed this in #13323 (comment)? It just hasn't been released yet?

  2. sobolevn commented on Sep 11, 2022

    @sobolevn
    MemberAuthor

    Sorry, I did not mention: I am using master version (0f17aff06ac1c05c442ba989e23655a2c6adbfbf) of course. We even have a test for it here:

    mypy/mypy/test/teststubtest.py

    Lines 1391 to 1403 in 0f17aff

    yield Case(
    stub="""
    class AP1:
    def some(self) -> int: ...
    """,
    runtime="""
    class AP1:
    @property
    @abstractmethod
    def some(self) -> int: ...
    """,
    error="AP1.some",
    )

    But, for some reason the example above is not reported.

  3. sobolevn commented on Sep 11, 2022

    @sobolevn
    MemberAuthor

    Oh, this is why:

                 class AP1: 
                     def some(self) -> int: ... 

    We miss @property decorator there.

  4. AlexWaygood commented on Sep 11, 2022

    @AlexWaygood
    Member

    Got it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions