Scope-level comments #2691
Replies: 5 comments 8 replies
-
We currently have no plans to add scope-level comments, so there's no roadmap to speak of. The Python typing standard defines line-level diagnostic suppression via a Pyright adds pyright-specific control at the file level using We might consider adding some form of block-level control if enough users indicate that it's important to them, but it would require some internal discussion about how to get the details right. Also, unless it goes through a PEP standardization process, such a solution would be pyright-specific and wouldn't work with other Python type checkers. Here's one somewhat-related issue in the pylance issue tracker: #282. In my experience, there's usually a better way to deal with type errors than suppressing them. A combination of type annotations, casts, and asserts takes care of the vast majority of type errors, and these approaches result in more robust code than simple suppression. If there are specific examples of code where you're struggling to find a straightforward way to address an error, please feel free to post to the discussion section, and we should be able to suggest some good approaches. |
Beta Was this translation helpful? Give feedback.
-
Thanks @erictraut - yes, I can understand it all. There are no struggles on my end, I am aware of all the other options, whether static or runtime ones, this works. It is simply that this additional capability could be very handy on its own and I opened the ticket because, like you said, perhaps enough people will express their interest as well. (My understanding being that you use GH tickets also to gather direct feedback and insights from programmers on what they are looking for). Regards. |
Beta Was this translation helpful? Give feedback.
-
Got it. Yes. I generally don't keep enhancement request tickets open in the pyright issue tracker if we don't have any immediate intent to address them. If a closed ticket gets enough feedback (thumbs-up, etc.), then we revisit it. In this particular case, I'm thinking that rather than closing the issue and waiting for feedback, it might be better to transfer it to the pylance-release repo. There it will be left open and perhaps receive more attention and discussion from other users. The number of pylance users is much higher than pyright users. (If you're not familiar with pylance, it's the full-featured language server extension for VS Code that builds upon pyright.) |
Beta Was this translation helpful? Give feedback.
-
Moving this issue to discussion as an enhancement request for comments and upvotes. |
Beta Was this translation helpful? Give feedback.
-
Genuinely not sure how to handle a library like dash which uses a weird _UNDEFINED type without scope level disabling of types |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
could you please add to your roadmap the implementation of Python scope-level pragma comments?
For instance:
Generally, this is useful when dealing with third-party libraries when one simply knows what to ignore.
There are various ways to work around such situations but simply having a way to explicitly drive the type checker with a pragma comment would be very useful.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions