Skip to content

Commit

Permalink
馃敡: Depend on typing_extensions only on Python <3.8 (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkin committed Dec 5, 2022
1 parent 28725fc commit 11756a1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions myst_parser/_compat.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
"""Helpers for cross compatibility across dependency versions."""
import sys
from typing import Callable, Iterable

from docutils.nodes import Element

if sys.version_info >= (3, 8):
from typing import Literal, Protocol, get_args, get_origin # noqa: F401
else:
from typing_extensions import Literal, Protocol, get_args, get_origin # noqa: F401


def findall(node: Element) -> Callable[..., Iterable[Element]]:
"""Iterate through"""
Expand Down
2 changes: 1 addition & 1 deletion myst_parser/_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from sphinx.directives import other
from sphinx.util import logging
from sphinx.util.docutils import SphinxDirective
from typing_extensions import get_args, get_origin

from ._compat import get_args, get_origin
from .config.main import MdParserConfig
from .parsers.docutils_ import Parser as DocutilsParser

Expand Down
2 changes: 1 addition & 1 deletion myst_parser/config/dc_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import dataclasses as dc
from typing import Any, Sequence

from typing_extensions import Protocol
from myst_parser._compat import Protocol


def validate_field(inst: Any, field: dc.Field, value: Any) -> None:
Expand Down
2 changes: 1 addition & 1 deletion myst_parser/parsers/docutils_.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from docutils import frontend, nodes
from docutils.core import default_description, publish_cmdline
from docutils.parsers.rst import Parser as RstParser
from typing_extensions import Literal, get_args, get_origin

from myst_parser._compat import Literal, get_args, get_origin
from myst_parser.config.main import (
MdParserConfig,
TopmatterReadError,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies = [
"mdit-py-plugins~=0.3.1",
"pyyaml",
"sphinx>=4,<6",
"typing-extensions",
'typing-extensions; python_version < "3.8"',
]

[project.urls]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_docutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import pytest
from docutils import VersionInfo, __version_info__
from typing_extensions import Literal

from myst_parser._compat import Literal
from myst_parser.mdit_to_docutils.base import make_document
from myst_parser.parsers.docutils_ import (
Parser,
Expand Down

0 comments on commit 11756a1

Please sign in to comment.