Closed kumaranvpl closed 2 months ago
Thanks for the report @kumaranvpl. Could you tell me which version of MkDocs you have installed?
Hello @pawamoy,
I am using following version of libraries:
mkdocs 1.6.1
mkdocs-autorefs 1.2.0
mkdocstrings 0.26.0
mkdocstrings-python 1.10.9
Thanks!
Unfortunately I am not able to reproduce the issue you describe. Could you set up a minimal reproducible example (zip archive or GitHub project) that I could use to investigate?
+1 to this. Just happened to me as well. Here is my setup.
griffe 1.2.0
mkdocs 1.6.1
mkdocs-autorefs 1.2.0
mkdocs-get-deps 0.2.0
mkdocs-material 9.5.34
mkdocs-material-extensions 1.3.1
mkdocstrings 0.26.0
mkdocstrings-python 1.11.1
The particular line it's complaining about for me is a Type Alias, e.g. MyVariable = str
. I can try to pull together a full repo including code, if you can't get it to repro.
Thanks @beijbom. Still cannot reproduce though, so yes, a full repo would be great :slightly_smiling_face:
Thanks for the report @kumaranvpl. Could you tell me which version of MkDocs you have installed?
Hello @pawamoy,
Checkout my repo - https://github.com/kumaranvpl/faststream/tree/main. Please clone it, create a venv(any 3.9+), install dependencies by running pip install -e ".[dev]"
and run the script ./scripts/build-docs.sh
.
This will throw the error AttributeError: 'dict' object has no attribute 'resolve_closest'
. I hope this helps with your debugging.
We also encountered this error when upgrading mkdocstrings to v.0.26.0 which included an upgrade of autorefs to 1.2.0
We added the following to the mkdocs.yml
as a workaround, but would be nice if it was not necessary
@kumaranvpl thanks, I'm able to reproduce the error within your repository. However that's far from a minimal reproduction example and that makes it hard to debug. Basically, in your project, self.config
is indeed an empty dict, while in my own (smaller) projects, self.config
is an instance of mkdocs_autorefs.plugin.AutorefsConfig
, which allows attribute access, and has resolve_closest
set to False
by default. What I don't understand is why the types are different from one project to another. This is why an MRE would be greatly appreciated.
OK I found the difference. It's when autorefs
is listed or not under plugins
(previously missed that because it needed to cross-ref a mkdocstrings object twice to trigger the error, not just a markdown heading). Working on a fix.
Fixed by mkdocstrings 0.26.1, which now instantiates the config
attribute of the autorefs plugin instance it creates itself.
Can confirm that 0.26.1 allows us to remove the aforementioned workaround - thanks for the quick fix!
@pawamoy Thanks for the quick fix. I can also confirm that with version 0.26.1
my project works. Sorry, I didn't had time to create a MRE.
No worries, you were all helpful 😊
Description of the bug
From version
1.2.0
, runningmkdocs build
command results in the errorAttributeError: 'dict' object has no attribute 'resolve_closest'
. This issue is not happening in version1.1.0
.I did some digging around, the error obviously happening at https://github.com/mkdocstrings/autorefs/blob/main/src/mkdocs_autorefs/plugin.py#L178 and the
self.config
returns an empty dictionary. Even aton_config
https://github.com/mkdocstrings/autorefs/blob/main/src/mkdocs_autorefs/plugin.py#L211, theself.config
value is an empty dictionary. But printing theself.config
inmkdocstrings
project at https://github.com/mkdocstrings/mkdocstrings/blob/main/src/mkdocstrings/plugin.py#L137 returns some value.This could be because of incorrect initialization/usage of config variable. Hopefully above info helps with debugging.
Full traceback
Full traceback
```python File "/home/userdev/project/venv/bin/mkdocs", line 8, inEnvironment information
mkdocs-autorefs
v1.2.0