microsoft / pyright

Static Type Checker for Python
Other
13.26k stars 1.43k forks source link

Per-file comments do not allow trailing comments #9237

Closed bersbersbers closed 3 hours ago

bersbersbers commented 4 hours ago

Describe the bug In per-file comments, adding a trailing comment breaks the comment. This is not true for per-line comments.

Code or Screenshots This works:

{slice(0)}  # pyright: ignore[reportUnhashable]  # microsoft/pyright#9236
c:\Git\project\bug5.py
  c:\Git\project\bug5.py:1:1 - error: Expression value is unused (reportUnusedExpression)
1 error, 0 warnings, 0 informations

This does not:

# pyright: reportUnhashable=false  # microsoft/pyright#9236
{slice(0)}
c:\Git\project\bug5.py
  c:\Git\project\bug5.py:1:29 - error: Pyright comment directive must be followed by "=" and a value of true, false, error, warning, information, or none
  c:\Git\project\bug5.py:2:1 - error: Expression value is unused (reportUnusedExpression)
  c:\Git\project\bug5.py:2:2 - error: Set entry must be hashable
    Type "slice" is not hashable (reportUnhashable)
3 errors, 0 warnings, 0 informations

While again, this does:

# pyright: reportUnhashable=false
{slice(0)}
  c:\Git\project\bug5.py:2:1 - error: Expression value is unused (reportUnusedExpression)
1 error, 0 warnings, 0 informations

VS Code extension or command-line pyright 1.1.384

erictraut commented 3 hours ago

Pyright is working as designed here. This isn't a bug.