jaraco / skeleton

A generic project skeleton for Python projects.
http://blog.jaraco.com/skeleton/
MIT License
121 stars 38 forks source link

Enable strict and disable "ignore missing imports" where viable #117

Open jaraco opened 5 months ago

jaraco commented 5 months ago

one-size-fits-all seems to me to be a strange goal for mypy configuration. Different projects will have different imports: some of which will have complete type stubs, some of which will have partial type stubs, some of which will have none.

I would recommend that you go strict everywhere, and ignore missing imports explicitly for specific packages as needed, rather than unconditionally ignore-missing-imports. That makes it clearer what is going on and - as here, perhaps! - encourages contributions to dependencies that are nearly well-typed.

_Originally posted by @dimbleby in https://github.com/jaraco/jaraco.classes/pull/13#discussion_r1544981101_

jaraco commented 5 months ago

That's fair. When skeleton projects originally started adopting typing and mypy, almost nothing would pass without the settings currently in place. Now at least some projects are able to adopt more strict settings.

One goal of skeleton is to limit the toil of once per project changes, so I'll explore how viable either of these settings might be across all of the projects:

ignore_missing_imports = False
strict = True
jaraco commented 5 months ago

I'm running this command to get an idea of how extensive is the reliance on the ignore_missing_imports setting:

pip-run jaraco.develop -- -m jaraco.develop.projects-run -t 'not fork' -- bash -c 'sed -i -e /ignore_missing_imports/d mypy.ini; tox -- -p no:cov -k mypy'

results

Avasam commented 1 month ago

I just saw this issue after creating https://github.com/jaraco/skeleton/pull/136 Whilst I agree that strict by default ought to be the norm, most jaraco / skeleton-based projects are too far to be ready. Most aren't even marked py.typed ! (ref: https://github.com/jaraco/skeleton/issues/98#issuecomment-1839814825) So in that PR I went with non-strict but a few useful checks still turned on.