Skip to content

feature: Allow using a decorator imported from another local module #6

@danielnelson

Description

@danielnelson

Is your feature request related to a problem? Please describe.

My project has a module where I switch between the stdlib and typing_extensions depending on the version of Python in use. It looks something like:

myproject/compat.py:

__all__ = [
    "deprecated",
]

if sys.version_info >= (3, 13):
    from warnings import deprecated
else:
    from typing_extensions import deprecated

Then in the rest of the project I do:

from myproject.compat import deprecated

@deprecate("this is deprecated")
def foo():
    pass

However, it seems this isn't recognized as the deprecated decorator because the decorator.callable_path is myproject.compat.deprecated.

Describe the solution you'd like

Maybe we could allow setting custom paths for the decorators? Maybe support any decorator with the function name deprecated (seems risky)? I'd rather not have to remove the compat module though or do the if/else outside of my compat.py where the decorator is used.

Describe alternatives you've considered

None

Additional context

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions