Skip to content

Stubtest thinks a property alias isn't read-only in stubs #19509

@Avasam

Description

@Avasam

Bug Report

I was using #6700 to track support for aliasing property. But even after #19297 (I just tested against mypy on master), stubtest gives the following error (example using pika):

error: pika.adapters.blocking_connection.BlockingConnection.exchange_exchange_bindings is read-only at runtime but not in the stub
Stub: in file E:\Users\Avasam\Documents\Git\typeshed\stubs\pika\pika\adapters\blocking_connection.pyi:88      
def (self: pika.adapters.blocking_connection.BlockingConnection) -> builtins.bool
Runtime:
<property object at 0x000001E022E79B70>

To Reproduce

# Runtime
class BlockingConnection:
    @property
    def exchange_exchange_bindings_supported(self):
        return True
    exchange_exchange_bindings = exchange_exchange_bindings_supported

# Stub
class BlockingConnection:
    @property
    def exchange_exchange_bindings_supported(self) -> bool: ...
    # error: exchange_exchange_bindings is read-only at runtime but not in the stub
    exchange_exchange_bindings = exchange_exchange_bindings_supported

Expected Behavior

There should be no stubtest error for valid property aliases.

Actual Behavior

(see error above)

Your Environment

  • Mypy version used: 1.18.0+dev.a56adc82f7dd747f400bb9267ec32b73d22de64e
  • Mypy command-line flags: (copied from the stubtest run) python.exe -m mypy.stubtest --mypy-config-file C:\Users\Avasam\AppData\Local\Temp\tmp5lugkyw4 --custom-typeshed-dir . pika --allowlist stubs\pika\@tests\stubtest_allowlist.txt
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: Python 3.13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions