Skip to content

Add packages and modules keys to config file format #9883

Closed
@trws

Description

@trws

Feature

Offer configuration variables for packages and modules to match the command-line flags, much like files matches listing files on the command line. Intended to work exactly like the command line flags, with the exception that they would not override a files key and having files and either of the new keys in the same config file would create a conflict.

Usage meant to be something like this (actual code this would work with linked below):

[mypy]
python_version = 3.7
packages=spack,builtin.packages,builtin_mock.packages
mypy_path=bin,lib/spack,lib/spack/external,var/spack/repos/builtin

To match a command line like mypy -p spack -p builtin.packages -p builtin_mock.packages

Pitch

The main use comes from, spack, a project I'm adding type checking to. It's a package manager where the libraries, tool and all package definition files are written in python. Having mypy check the library without arguments is simple, I can just write a files key that covers all files and it will work fine, but the packages are in a structure like this:

./var/spack/repos/
├── builtin
│   ├── packages
│   │   ├── 3proxy
│   │   │   └── package.py
│   │   ├── abduco
│   │   │   └── package.py
│   │   ├── abi-compliance-checker
│   │   │   └── package.py
... etc.

If I use a files key for these, they are all treated as duplicate package modules, and mypy errors out (probably appropriately). They can however be treated as a package, and mypy works quite well on the library and the whole package tree in that mode (especially after the recursive checking fixes). The trick now is that I can't make running mypy check the packages tree without arguments or wrapping or similar.

I'd like to add support for specifying these in the configuration file to bring them up to the same level of support as listing files, as mentioned in PR #9834.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions