Skip to content

Block-level comments #2607

@dsuch

Description

@dsuch

Hello,

in a way, this is similar to #2606 (Scope-level comments).

Here, I ask you to add the capability to let comments decide what to ignore, disable or enable within the boundaries of entire blocks of code.

For instance:

# pyright: strict

def func():
    # pyright: disable=reportUnknownMemberType
    socket = self.socket.accept()
    socket.invoke_another_urecognised_method()
    # pyright: enable=reportUnknownMemberType

    # We are back to the strict mode now
    ...

This could work across functions or probably any lines of code, which is why it is not the same as #2606:

# pyright: strict

# pyright: disable=reportUnknownMemberType

def func1():
    ...

def func2():
    ...

# pyright: enable=reportUnknownMemberType

# Back to strict now

However, making it work with completely arbitrary blocks would be likely impractical and academic, e.g. I do not see any use case for such comments to begin in the middle of one function only to end in the middle of another.

Yet, I can definitely see it work across a few functions, a handful of related classes etc.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions