pdoc3 / pdoc

:snake: :arrow_right: :scroll: Auto-generate API documentation for Python projects
https://pdoc3.github.io/pdoc/
GNU Affero General Public License v3.0
1.12k stars 145 forks source link

Replace Union[T, NoneType] in all type annotations by Optional[T]. #325

Closed hhoppe closed 3 years ago

hhoppe commented 3 years ago

This addresses https://github.com/pdoc3/pdoc/issues/324

Also, uniformly removes prefix "typing." from type annotations, and replaces "NoneType" by "None", so that the function signatures look more similar to those commonly found in source code.

hhoppe commented 3 years ago

@kernc Unfortunately it looks like we worked in parallel... :-) Interesting to compare the solutions and see many similarities. Please have a look to see if my efforts have useful ideas. Thanks.

hhoppe commented 3 years ago

The changes in my very last commit "Fix for flake8" https://github.com/pdoc3/pdoc/pull/325/commits/d0101475868d52cf24aa69976891931011adbbae is wrong. Sorry about that.

I did a checkout of https://github.com/pdoc3/pdoc/commit/6bd00e13a2a5839ba0b20afa8b4f6321164942a2 and its output exactly reproduces what I had generated, so I'm happy with the changes in the main branch.

kernc commented 3 years ago

Sincere apologies. I went to investigate, and then I had half of it working and couldn't just throw it away. I also realized even existing nptyping. and NewType replacements didn't trigger when nested, so something had to be done. Thanks for verifying.