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.validate keeps 'mdx_configs' values across different instances #2289
Comments
It took me a couple minutes but I figured out the issue. The data is not shared across instances of the Of course, this matters when using the live reload server. Each reload also reloads and validates the config. A change to the config should be reflected in the reload. I wonder if perhaps we need to change the way we are loading the |
Perhaps we should add some sort of |
I don't think I agree with your assessment that this is a general / likely recurring problem. Here it really is specific to the way I also see that good care was taken not to accidentally mutate defaults from a schema, which could've been a whole another class of bugs and is what I suspected initially. Anyway, so how could we make this less confusing? Make those instances actually act as classes that can themselves be instantiated? Are we delving into metaclasses? Let me just cut myself short there,... from what I said above I just think that this doesn't require any significant rework. And sure, you could introduce this |
The thinking was that potential future options or options for third party plugins could also run into this issue. True, the classes would need to make use of the However, it is probably better to not even need to consider that when creating option classes. One simple solution that occurs to me is to regenerate the scheme each time. Therefore, in DEFAULT_SCHEME = (
...
) we would have: def get_scheme():
return (
...
) Then where we currently make reference to |
Replace the global variable `mkdocs.config.DEFAULT_SCHEMA` with the function `mkdocs.config.defaults.get_schema()`. An instance is no longer created on import (eliminating circular imports under certain circumstances) and each call to `get_schema()` builds a new instance of each object. Fixes mkdocs#2289.
Replace the global variable `mkdocs.config.DEFAULT_SCHEMA` with the function `mkdocs.config.defaults.get_schema()`. An instance is no longer created on import (eliminating circular imports under certain circumstances) and each call to `get_schema()` builds a new instance of each object. Fixes #2289.
I still think #2353 was not necessary. It happens to fix some cases but not others - see #2909 now. The reason I think so is that the ConfigItem instances are just part of the definition of a config, you shouldn't need to make a new definition of the config every time. The objects just shouldn't store state of an individual item in them. |
The text was updated successfully, but these errors were encountered: