Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmdline --always-true to override the config #849

Open
jorenham opened this issue Dec 26, 2024 · 4 comments
Open

cmdline --always-true to override the config #849

jorenham opened this issue Dec 26, 2024 · 4 comments
Labels

Comments

@jorenham
Copy link
Collaborator

I can't use --always-false=MYPY if I already have always_true = "MYPY" in the config:

$ mypy --always-false=MYPY .
usage: mypy [-h] [-v] [-V] [more options; see below]
            [-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
mypy: error: You can't make a variable always true and always false (MYPY)

There's no need to disallow this whatsoever. The CLI-flags should obviously take precedence.

This is blocking me from running basedmypy in the CI (of optype) using different numpy versions. I don't want to duplicate the entire mypy config for all 6 different numpy versions, or do some hacky in-place pyproject.toml modification or something.

@jorenham
Copy link
Collaborator Author

I ended up writing a bmp-runner script:
https://github.com/jorenham/optype/blob/de3be4648ed7687bcbb9d60f2d423d5252c7f390/scripts/bmp.py

So as far as I'm concerned, it's not all that urgent anymore 🤷🏻

@KotlinIsland
Copy link
Owner

i've run into this kind of stuff before and it's an absolute nightmare, i think it would require a complete rewrite of the arg parsing

@jorenham
Copy link
Collaborator Author

overriding seems to be possible though:

basedmypy/mypy/main.py

Lines 1439 to 1447 in f1a7595

# Paths listed in the config file will be ignored if any paths, modules or packages
# are passed on the command line.
if not (special_opts.files or special_opts.packages or special_opts.modules):
if options.files:
special_opts.files = options.files
if options.packages:
special_opts.packages = options.packages
if options.modules:
special_opts.modules = options.modules

@KotlinIsland
Copy link
Owner

feel free to take a crack at it, when we have run into this we resorted to writing additional config files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants