black icon indicating copy to clipboard operation
black copied to clipboard

[2097] Fix is_type_comment

Open itxasos23 opened this issue 3 years ago • 3 comments

Description

Issue https://github.com/psf/black/issues/2097 raised the issue that is_type_comment only works for comments starting with # type:, and more spaces/tabs between # and type, or typeand : 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:

  • Using regex. Is there a way to perform this check fast, while not changing the ast parsing?
  • Testing. I want to unit test the method to ensure it works as expected, but I don't see tests for similar functions in the tests directory. Is this by design?
  • Is this user facing?
  • Do you think it makes sense to parse these type_comments into its component tokens: #, type, : and the rest? I believe that would help with fixing the formatting.

Checklist - did you ...

  • [ ] Add an entry in CHANGES.md if necessary?
  • [X] Add / update tests if necessary?
  • [ ] Add new / update outdated documentation?

itxasos23 avatar Oct 17 '22 20:10 itxasos23

diff-shades reports zero changes comparing this PR (1303fb45913c8b19b78a9bd7f41d2cbccdac8e31) to main (26de5f91c37b825214f4ee0a9096f1cd34212e76).


What is this? | Workflow run | diff-shades documentation

github-actions[bot] avatar Oct 17 '22 22:10 github-actions[bot]

I'd argue this PR doesn't merit a changelog entry by now (maybe it does if we decide to reformat # type:* comments?)

itxasos23 avatar Oct 20 '22 20:10 itxasos23

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.

ichard26 avatar Oct 25 '22 00:10 ichard26