-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
What format should per-file options take? #3432
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
Comments
I'd want something more like
with an option to split options into multiple lines
Can't be simpler than that. |
Personally, I think I'd lean towards Option 1. It keeps a consistent format with another way in which you configure mypy (namely, the commandline), and it's more concise than Option 2. I do see the benefit of @miedzinski's suggestion, but think that losing the |
We should definitely not invent a new format, but follow either the command line or the config file. I personally prefer using the config file format here, because in a sense it is the "canonical" format. The rule could be: when you put options in a file, you use the canonical format. The config file format also makes it clear(er) that you can only specify "per-file" flags here, e.g. the various "strict" flags, and not "global only" flags such as The config file format is also naturally a multi-line format, so we won't have to make up rules for multiple lines of flags. |
If you really want to go for configparser's syntax in source code (which seems really weird), we should invent an end-of-mypy-config marker so it won't mix with possibly unrelated comments (e.g. flake8). |
Why do you find weird? Do you have examples of other tools that have in-file configuration?
A blank (non-comment) line should suffice.
What is the format of flake8 comments? (I only know of |
I simply don't like it and prefer my suggestion or opt 1.
You can put |
I'd prefer using the config file option syntax but without a section header. For example:
Alternatively, we could use something like Rationale:
I agree with @gvanrossum that it's better to mimic the per-file config file options here, since the command line options are global. Also, it's plausible that we will eventually have some options only valid within the config file. Having a very large number of command-line options is a little awkward, since |
@JukkaL, @gvanrossum, @ddfisher: Is that enough consensus on @JukkaL's proposal that I should go ahead and implement it? It wouldn't be a huge deviation from the code I already have, which is nice. |
Let's go with Jukka's proposal. Note that you can use hyphens or underscores in config variable names, internally it's all converted to hyphens. |
This was done at some point https://mypy.readthedocs.io/en/stable/inline_config.html |
In #3388, I'm implementing in-file overrides for mypy options. Thus far, two different formats have come up, and I was asked to open this to come to an agreement on the preferred format.
Option 1: CLI-style
Option 2: Config-style
In both cases, I'm proposing that these options should have to be part of the first contiguous comment block in the file (preceded at most by lines of whitespace).
The text was updated successfully, but these errors were encountered: