Closed
Description
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
Labels
No labels