Skip to content
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

Don't bork on typing_extensions.Literal #527

Merged
merged 2 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
([#521](https://github.com/mitmproxy/pdoc/pull/521), @mikkelakromann)
- Fix a crash in pdoc 13.0.0 when `__init__.py` is passed as a file to pdoc.
([#522](https://github.com/mitmproxy/pdoc/pull/522), @mhils)
- Add rudimentary support for `typing_extensions.Literal` on Python 3.7.
([#527](https://github.com/mitmproxy/pdoc/pull/527), @mhils)

## 2023-02-19: pdoc 13.0.0

Expand Down
7 changes: 5 additions & 2 deletions pdoc/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ def __get__(self, instance, owner=None):

# There is no Literal on 3.7, so we just make one up. It should not be used anyways!

class Literal:
pass
try:
from typing_extensions import Literal
except ImportError:
class Literal:
pass

# get_origin is adapted from
# https://github.com/python/cpython/blob/863eb7170b3017399fb2b786a1e3feb6457e54c2/Lib/typing.py#L1474-L1515
Expand Down