Skip to content

Do we need a standard way of silencing checkers? #16

Closed
@JukkaL

Description

@JukkaL

It may be useful to have a way of saying "don't complain about this type error; trust me, I know what I'm doing". For example, consider this code:

def foo(f: Function[...]) -> None:
    f._attr_ = True   # Error? But what if this is intentional?

A type checker would probably not allow assigning to an attribute of a function. However, sometimes programmers do this, and it works for user-defined functions. Maybe we could have a standard way of asking the type checker to shut up and ignore this particular warning only.

If we don't specify this in the PEP, there could end up being multiple tool-specific ways of doing this.

Apparently pylint supports something like this:

# pylint: disable=fixme

Hack also has something like this (example copied from Hack docs):

<?hh
function unsafe_foo(int $x, int $y): int {
  if ($x > $y) {
    // UNSAFE
    return "I am not checked by the type checker"; // Covered by UNSAFE
  }
  return 34; // NOT covered by UNSAFE
}

Link to relevant Hack docs: http://docs.hhvm.com/manual/en/hack.modes.unsafe.php

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions