Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Parse deprecation message from expression arguments #5

Merged
merged 5 commits into from
Dec 10, 2024

Conversation

connesy
Copy link
Contributor

@connesy connesy commented Dec 10, 2024

Update the deprecated method to parse the deprecation message from the expression arguments instead of relying on string parsing.

Fixes #4

@connesy
Copy link
Contributor Author

connesy commented Dec 10, 2024

@pawamoy Not sure how to fix the typing issue, as the Decorator.value field is typed as str | Expr, but the actual value is ExprCall?

@pawamoy
Copy link
Member

pawamoy commented Dec 10, 2024

I'm far from a typing expert so I'll simply recommend adding a # type: ignore[...] comment for the issue you mention 😅 As far as I can tell it's not possible to use the deprecated decorator without arguments, so it should always be an ExprCall.

@connesy
Copy link
Contributor Author

connesy commented Dec 10, 2024

I'm far from a typing expert so I'll simply recommend adding a # type: ignore[...] comment for the issue you mention 😅 As far as I can tell it's not possible to use the deprecated decorator without arguments, so it should always be an ExprCall.

I think the bigger question is whether the Decorator.value attribute should be annotated as str | Expr. Will it always be a ExprCall for an instance of Decorator?

@pawamoy
Copy link
Member

pawamoy commented Dec 10, 2024

No! Decorators can be arbitrary expressions since a few Python versions:

@(lambda func: some_wrapper(func, some_arg=0))
def my_func(): ...

Even before that they could have been a single name, or an attribute (no calls):

@dec
def func(): ...

@obj.dec
def func(): ...

@connesy
Copy link
Contributor Author

connesy commented Dec 10, 2024

I've added a check for whether decorator.value is an instance of ExprCall: 5c6acc4 (#5)

Co-authored-by: Timothée Mazzucotelli <[email protected]>
Copy link
Member

@pawamoy pawamoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again!

@pawamoy pawamoy merged commit 0b5ffd3 into mkdocstrings:main Dec 10, 2024
26 checks passed
@connesy
Copy link
Contributor Author

connesy commented Dec 10, 2024

Thank you!
Apologies for taking up your night. I appreciate the fast responses 🙂

You are doing great work with these packages 👍

@pawamoy
Copy link
Member

pawamoy commented Dec 10, 2024

No apologies required ☺️! Thanks for your contributions and for the kind words ❤️

@pawamoy
Copy link
Member

pawamoy commented Dec 10, 2024

Version 1.1.0 released by the way!

@connesy connesy deleted the bugfix-message-cut-after-comma branch December 11, 2024 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Message is cut short following a comma
2 participants