-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 "# pyright: ignore" comment mobility #3661
base: main
Are you sure you want to change the base?
Conversation
dd659aa
to
03600c9
Compare
Should we add this to |
Ah, my understanding is that the pragma stuff only applies to string concatenation and splitting. I'm really hoping to fix the annoyance of having blah_blah_blah = [ # pyright: ignore
...
] shift into blah_blah_blah = [
...
] # pyright: ignore The behavior in Line 263 in de65741
|
Co-authored-by: James Hilton-Balfe <gobot1234yt@gmail.com>
Hi! I wanted to see if there any concerns about gettin this merged other than fixing the conflicts? If it isn't clear, we get scenarios where black transform code from this some_long_variable_name = some_long_dict_name[0] # pyright: ignore[reportGeneralTypeIssues] to this some_long_variable_name = some_long_dict_name[
0
] # pyright: ignore[reportGeneralTypeIssues] where after the transformation, the ignore is no longer being applied to the actual line causing pyright to error. This looks similar to the Our current solution is use cast or do a rename that looks like this a = some_long_dict_name[0] # pyright: ignore[reportGeneralTypeIssues]
some_long_variable_name = a # pyright: ignore[reportGeneralTypeIssues] which are both not ideal scenarios and is very tedious and adds unnecessary bloat to the codebase. Also using |
@JelleZijlstra |
I need to look more into this to figure out exactly how we use these, but a few thoughts:
|
Would it make more sense to add a Black configuration option opting certain types of patterned comments into the unsplittable behavior, then? |
Would love to see this feature, it's much needed. |
For my education, can you please elaborate how they are treated differently? |
Looks like the best path forward for our company at the moment is to fork black and apply this patch. We really need this functionality soon. This is very unfortunate, I hope there is a path forward in upstream to resolve this. |
Actually just tried applying the patch on |
Description
Hi! It looks like you have some special handling for
# type: ignore
comments to avoid moving said comments around due to positional meaning. I think this same special handling should also apply to# pyright: ignore
comments.The use case for
# pyright: ignore
comments is being able to ignore Pyright-specific diagnostic rules that might not make sense in the context of more generic# type: ignore
comments.Checklist - did you ...
CHANGES.md
if necessary?