Skip to content
New issue

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

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

Already on GitHub? # to your account

TYPE_CHECKING block scan bug #351

Closed
Tracked by #365
Dliwk opened this issue Feb 14, 2022 · 2 comments
Closed
Tracked by #365

TYPE_CHECKING block scan bug #351

Dliwk opened this issue Feb 14, 2022 · 2 comments
Labels

Comments

@Dliwk
Copy link
Contributor

Dliwk commented Feb 14, 2022

Problem Description

Error while generating documentation for annotated variable in module with TYPE_CHECKING block.

pdoc does it standard stuff from #293, but modifies content of self.obj.__dict__ (i.e. adding there things imported from TYPE_CHECKING block) while being within loop and after that hit RuntimeError: dictionary changed size during iteration.

Steps to reproduce the behavior:

  1. https://gist.github.com/Dliwk/81dfaa01e79f8042e477a6f1769e6a45
  2. pdoc module

System Information

pdoc: 10.0.0 (+1, commit eb686bc)
Python: 3.10.2
Platform: Linux-5.16.5-arch1-1-x86_64-with-glibc2.33

@Dliwk Dliwk added the bug label Feb 14, 2022
@Dliwk
Copy link
Contributor Author

Dliwk commented Feb 14, 2022

Perhaps we just need to execute code in these blocks right after importing them (and before entering this loop). 🤔

@mhils
Copy link
Member

mhils commented Feb 14, 2022

Thanks for the great repro - fixed!

Fun to see how the existing test case for TYPE_CHECKING did almost the same, but missed it by an inch (diff). 😅

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

No branches or pull requests

2 participants