-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[2097] Fix is_type_comment #3339
Conversation
I'd argue this PR doesn't merit a changelog entry by now (maybe it does if we decide to reformat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Hopefully a maintainer will answer the questions on your PR description :)
Hey! I just wanted to say thank you for submitting a PR. I know us maintainers haven't been very active reviewing PRs lately and that's disheartening. I speak for the rest of the maintainership team that we really appreciate all of your work. I promise I've seen this come into my inbox and care about it. I've just been really busy lately and finding time (and the energy) to do reviews has been tough. I'll try my best to find time this week. Thanks again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know there's probably been discussion, but I don't like we're introducing a regex to parse for broken syntactical usages of a deprecated (or are there valid uses I don't know of for type comments) feature of Python ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this affect formatting in practice? It's not clear to me whether this will need to go in the preview style.
Also, you need a changelog entry.
@@ -778,12 +779,18 @@ def is_import(leaf: Leaf) -> bool: | |||
) | |||
|
|||
|
|||
is_type_comment_regex = re.compile(r"^#[\s\t]+type[\s\t]*:") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't \t
included in \s
?
Description
Issue #2097 raised the issue that
is_type_comment
only works for comments starting with# type:
, and more spaces/tabs between#
andtype
, ortype
and:
are valid as per typed-ast/ast, but not black.This PR (for now!) only tries to make is_type_comment be consistent with typed-ast, not to remove the extra spaces/tabs if they are present.
I'd like some guidance as to:
#
,type
,:
and the rest? I believe that would help with fixing the formatting.Checklist - did you ...
CHANGES.md
if necessary?