Skip to content
This repository was archived by the owner on Sep 3, 2026. It is now read-only.
This repository was archived by the owner on Sep 3, 2026. It is now read-only.

Crash on @property + @deprecated #1531

Closed

Description

@JelleZijlstra

In python/typeshed#11009, I tried to add the deprecated decorator (PEP 702) to a property:

from typing_extensions import deprecated

class CodeType:
    @property
    @deprecated("message")
    def co_lnotab(self) -> bytes: ...

But pytype crashes with a ParseError (https://github.com/python/typeshed/actions/runs/6839481445/job/18597693717?pr=11009):

pytype.pyi.types.ParseError:   File: "/home/runner/work/typeshed/typeshed/stdlib/types.pyi", line 150
    def co_lnotab(self) -> bytes: ...
   ^
ParseError: Too many decorators for co_lnotab: property, deprecated

Ideally pytype should support @deprecated and emit warnings for deprecated properties, but failing that, it should just ignore the decorator.

Activity

  1. JelleZijlstra commented on Nov 18, 2023

    @JelleZijlstra
    ContributorAuthor

    It also crashes on __init__ methods where one variant is deprecated (pytype.pytd.codegen.function.OverloadedDecoratorError: Overloaded signatures for __init__ disagree on decorators: https://github.com/python/typeshed/actions/runs/6916103348/job/18815781379?pr=11009).

    And on deprecated classmethods (https://github.com/python/typeshed/actions/runs/6916179270/job/18815978232?pr=11009):

    pytype.pyi.types.ParseError:   File: "/home/runner/work/typeshed/typeshed/stdlib/datetime.pyi", line 269
        def utcfromtimestamp(cls, __t: float) -> Self: ...
       ^
    ParseError: Too many decorators for utcfromtimestamp: classmethod, deprecated
    
  2. self-assigned this
    on Nov 20, 2023
  3. JelleZijlstra commented on Nov 22, 2023

    @JelleZijlstra
    ContributorAuthor

    Thanks for the quick fix!

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions