From ec8ce107f05fd56e5bd08e5b8e2651876b66b686 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 31 Mar 2023 03:37:02 +0200 Subject: [PATCH 1/2] don't bork on `typing_extensions.Literal` --- CHANGELOG.md | 1 + pdoc/_compat.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14f69cfa..62f374de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ([#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. ## 2023-02-19: pdoc 13.0.0 diff --git a/pdoc/_compat.py b/pdoc/_compat.py index 5f4b90e8..312ae065 100644 --- a/pdoc/_compat.py +++ b/pdoc/_compat.py @@ -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 From 0b5866e706d4602b33ab8b9463d5bbc1e8213ed2 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Fri, 31 Mar 2023 01:38:08 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62f374de..9c8934ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - 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