Support local and dynamic class- and static-method decorators#8592
Merged
charliermarsh merged 2 commits intoastral-sh:mainfrom Nov 10, 2023
Merged
Support local and dynamic class- and static-method decorators#8592charliermarsh merged 2 commits intoastral-sh:mainfrom
charliermarsh merged 2 commits intoastral-sh:mainfrom
Conversation
335c989 to
bc25465
Compare
bc25465 to
c80e0b2
Compare
Contributor
|
Member
|
I went back and forth on this a bit but ultimately I think it makes sense in the interest of pragmatism and matching user expectation. |
charliermarsh
approved these changes
Nov 10, 2023
Member
charliermarsh
left a comment
There was a problem hiding this comment.
Thanks @ThiefMaster! I just modified the PR to break the logic out into standalone functions, and we also now always run the match checks rather than only if it's not an import.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This brings ruff's behavior in line with what
pep8-namingalready does and thus closes #8397.I had initially implemented this to look at the last segment of a dotted path only when the entry in the
*-decoratorssetting started with a., but in the end I thought it's better to remain consistent w/pep8-namingand doing a match against the last segment of the decorator name in any case.If you prefer to diverge from this in favor of less ambiguity in the configuration let me know and I'll change it so you would need to put e.g.
.expressionin theclassmethod-decoratorslist.Test Plan
Tested against the file in the issue linked below, plus the new testcase added in this PR.