Mypy: `--strict` is too strict to be useful

Created on 21 Oct 2019  路  4Comments  路  Source: python/mypy

We provide a --strict flag that is strict enough that we can not use it in mypy itself, which is one of the most carefully typed projects I know of.

We should possibly consider removing some flags from strict.

  • disallow_return_any? (see https://github.com/python/mypy/issues/7765)
needs discussion

Most helpful comment

I like the idea of making --strict only strict enough that we can reasonably use it in mypy. We could also support an ever stricter mode, such as --strict --strict that would enable more options still.

All 4 comments

I've been thinking about something related recently 鈥撀營 think it'd be useful to have a way to disable some specific checks while enabling strict mode. So hypothetically --strict --allow-return-any would enable all strict checks but --disallow-return-any. Ideally strict could also go in the config file but that's another issue.

As it is now I often have mypy configurations that are quite repetitive and when a new check is introduced there's no way to have it enabled automatically after upgrading mypy (although I understand some people wouldn't like it).

@jstasiak -- I think overriding specific parts of --strict is actually currently supported. For example, I can suppress the return-any errors by doing mypy --strict --no-warn-return-any blah.py.

Somewhat tangentially: maybe we should rename --warn-return-any to --disallow-return-any. It'd definitely be more consistent that way.

Lovely, I completely missed that! (+1 on renaming here)

I like the idea of making --strict only strict enough that we can reasonably use it in mypy. We could also support an ever stricter mode, such as --strict --strict that would enable more options still.

Was this page helpful?
0 / 5 - 0 ratings