-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Config inheritance #4366
Comments
This is something we've discussed (and rejected) previously in this issue. The config mechanism in pyright is already very complex because it composes configuration information from many sources, and the rules for how each setting composes is already complex to maintain and describe. For that reason, I'm reluctant to add yet more complexity to this. It's something we might consider if there's sufficient demand, but so far, you're only the second person to request it, and the other issue hasn't received any further upvotes. |
I don't want to open a new issue, but would just like to file a +1 for this feature. Duplicating pyright configs for a monorepo is becoming more and more unwieldy, and we can't merge projects unfortunately |
@erictraut Could you elaborate on your statement regarding the complexity of the request? From a user point of view, it seems that we have (and are forced to have) a single source of truth for our I know you mentioned in the other issue that it needs to merge things like language server and CLI settings, but to me it seems kind of besides the point? Ultimately, we are just talking about the file configuration, and allowing replacement/modulation/merge behavior specifically on the file config. I am tech lead in a relatively small (30ish engineers) software organization, but despite our size, our software stack is spread across close to 250 repositories in GitHub, roughly a quarter to a third of which at least are Python. We manage common linter configurations via dev containers and NPM package installs as distributable artifacts, and we aim for uniformity and standardization in our software, which of course means uniformity and standardization in our linter configurations. I'm sure this is not an unusual circumstance in enterprise settings. The ability to share/merge/inherit configurations would be tremendously valuable in this setting. Thanks for all the work on |
@jamestrousdale, I think this is more complex than simply merging two JSON documents. These configurations are not simple key/value pairs. They involve lists, dictionaries, and nested objects. I think that doing a merge at the top level of the namespace will produce problematic results. The internal logic that we have for merging CLI options, language server settings, and config file settings is quite complex. I'm interested in understanding your use case in more detail. You mentioned that you have close to 250 github repos. That's very different than the OP for this issue. In his case, he had a single monorepo. I can understand how a common config file would work for a monorepo, but it's less clear how it would work for independent repos. Where would the common config be checked in, and how would it be applied to each of the repos? If the answer is that you programmatically generate a dev container for each project, then I would think that you could easily write a script that merges a shared pyright config file with project-specific configs and applies the merge behaviors that you desire. Is that a viable solution? |
@erictraut Sure - like I mentioned in passing in my post, we manage shared configurations in a couple of different ways - either by packing them into dev containers or distributing them as NPM packages (which have no actual code in them, but give us a systematic way to "install" the configurations). For example, we do this with And yes, you are right, we can write a script to generate our own flavor of a merged pyright configuration, and indeed we may end up doing this, but for us it's an extra layer of tooling/abstraction/maintenance we'd prefer to avoid, obviously, if what we needed came "batteries included" with the tool in question. There are always edge cases on type checking and there's certainly no one size fits all when it comes to type checker configuration (for example, we have to turn off certain things when we run on projects which use a lot of I understand it may not be a priority given, as you've mentioned a couple of times, the lack of apparent popularity of the feature and the complexity you've explained - I just wanted to explain our use case in enterprise software development and our group's particular way of working. Thanks! |
Thanks for the details. This issue has received a moderate number of upvotes, so perhaps it's worth considering. I'll discuss with the maintainers of pylance to see if they have any opinions and/or concerns about an "extends" feature. Here are some design considerations that we'll need to consider.
|
Hi @erictraut - thanks for the consideration. My thoughts on your questions
|
|
Yeah, that's what I meant. Relative paths within a config file would be resolved relative to the location of that config file. |
As for "defineConstant", it's not clear that the user intends to concatenate. You could make the same case for "include", "exclude", "ignore", "strict", "extraPaths", or "executionEnvironments". Rather than guessing the user's intent, I'd prefer to be consistent and always overwrite. This provides the most flexibility. It's also the simplest to explain in the documentation and get correct in the implementation. |
…iguration option. This addresses #4366.
This feature will be included in the next release of pyright. |
This is included in pyright 1.1.365. |
Is your feature request related to a problem? Please describe.
I work with pyright in a large monorepo with ~70 python packages (Dagster). Because some packages have dependency conflicts with one another, they can't all be installed in the same Python environment. This prevents us from having a single pyright config in a root
pyproject.toml
that configures a single pyright instance (which would be the ideal scenario). Instead, @erictraut recommended here that we:This is a feasible solution, but it is arduous to maintain given the way pyright is currently configured. The only settings we need to vary across packages are import resolution-related settings like
venv
,venvPath
,extraPaths
,include
,exclude
. All other settings should be constant across packages in the repo. Currently, there is no way to factor out these common settings without some kind of build step for pyright config-- they have to be duplicated in each individual pyright configuration file.Describe the solution you'd like
Support an
extends
key in config that takes a path to another config file. Use this to merge the settings of the two configuration files:Additional context
This sort of feature is very useful for monorepo development and is available in many other linter tools. It is also now supported by the super-fast Python linter Ruff.
The text was updated successfully, but these errors were encountered: