Skip to content

Commit

Permalink
⬆️ UPGRADE: Drop Python 3.7 (#772)
Browse files Browse the repository at this point in the history
Python 3.7 is now end-of-life
  • Loading branch information
chrisjsewell committed Jun 5, 2023
1 parent a784880 commit 0bd853b
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 31 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ repos:
- sphinx~=5.0
- markdown-it-py>=1.0.0,<3.0.0
- mdit-py-plugins~=0.3.4
- types-urllib3
files: >
(?x)^(
myst_parser/.*py|
Expand Down
10 changes: 6 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,18 @@

# -- Autodoc settings ---------------------------------------------------

autodoc2_packages = ["../myst_parser"]
autodoc2_exclude_files = ["_docs.py"]
autodoc2_packages = [
{
"path": "../myst_parser",
"exclude_files": ["_docs.py"],
}
]
autodoc2_hidden_objects = ["dunder", "private", "inherited"]
autodoc2_replace_annotations = [
("re.Pattern", "typing.Pattern"),
("markdown_it.MarkdownIt", "markdown_it.main.MarkdownIt"),
]
autodoc2_replace_bases = [
("myst_parser._compat.Protocol", "typing.Protocol"),
("myst_parser._compat.TypedDict", "typing.TypedDict"),
("sphinx.directives.SphinxDirective", "sphinx.util.docutils.SphinxDirective"),
]
autodoc2_docstring_parser_regexes = [
Expand Down
12 changes: 0 additions & 12 deletions myst_parser/_compat.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
"""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, TypedDict, get_args, get_origin
else:
from typing_extensions import ( # noqa: F401
Literal,
Protocol,
TypedDict,
get_args,
get_origin,
)


def findall(node: Element) -> Callable[..., Iterable[Element]]:
"""Iterate through"""
Expand Down
3 changes: 1 addition & 2 deletions myst_parser/_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations

import io
from typing import Sequence, Union
from typing import Sequence, Union, get_args, get_origin

from docutils import nodes
from docutils.frontend import OptionParser
Expand All @@ -13,7 +13,6 @@
from sphinx.util.docutils import SphinxDirective

from myst_parser.parsers.docutils_ import to_html5_demo
from ._compat import get_args, get_origin
from .config.main import MdParserConfig
from .parsers.docutils_ import Parser as DocutilsParser
from .warnings_ import MystWarnings
Expand Down
4 changes: 1 addition & 3 deletions myst_parser/config/dc_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
from __future__ import annotations

import dataclasses as dc
from typing import Any, Sequence

from myst_parser._compat import Protocol
from typing import Any, Protocol, Sequence


def validate_field(inst: Any, field: dc.Field, value: Any) -> None:
Expand Down
2 changes: 1 addition & 1 deletion myst_parser/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
Sequence,
Set,
Tuple,
TypedDict,
Union,
)

from myst_parser._compat import TypedDict
from myst_parser.warnings_ import MystWarnings
from .dc_validators import (
deep_iterable,
Expand Down
4 changes: 1 addition & 3 deletions myst_parser/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
import re
import zlib
from dataclasses import asdict, dataclass
from typing import IO, TYPE_CHECKING, Iterator
from typing import IO, TYPE_CHECKING, Iterator, TypedDict
from urllib.request import urlopen

import yaml

from ._compat import TypedDict

if TYPE_CHECKING:
# domain_type:object_type -> name -> (project, version, loc, text)
# the `loc` includes the base url, also null `text` is denoted by "-"
Expand Down
4 changes: 3 additions & 1 deletion myst_parser/parsers/docutils_.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
Dict,
Iterable,
List,
Literal,
Optional,
Sequence,
Set,
Tuple,
Union,
get_args,
get_origin,
)

import yaml
Expand All @@ -20,7 +23,6 @@
from docutils.parsers.rst import Parser as RstParser
from docutils.writers.html5_polyglot import HTMLTranslator, Writer

from myst_parser._compat import Literal, get_args, get_origin
from myst_parser.config.main import (
MdParserConfig,
TopmatterReadError,
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand All @@ -32,15 +32,14 @@ keywords = [
"docutils",
"sphinx",
]
requires-python = ">=3.7"
requires-python = ">=3.8"
dependencies = [
"docutils>=0.15,<0.20",
"jinja2", # required for substitutions, but let sphinx choose version
"markdown-it-py>=1.0.0,<3.0.0",
"mdit-py-plugins~=0.3.4",
"pyyaml",
"sphinx>=5,<7",
'typing-extensions; python_version < "3.8"',
]

[project.urls]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_docutils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import io
from dataclasses import dataclass, field, fields
from textwrap import dedent
from typing import Literal

import pytest
from docutils import VersionInfo, __version_info__

from myst_parser._compat import Literal
from myst_parser.mdit_to_docutils.base import make_document
from myst_parser.parsers.docutils_ import (
Parser,
Expand All @@ -23,7 +23,7 @@
def test_attr_to_optparse_option():
@dataclass
class Config:
name: Literal["a"] = field(default="default") # noqa: F821
name: Literal["a"] = field(default="default")

output = attr_to_optparse_option(fields(Config)[0], "default")
assert len(output) == 3
Expand Down

0 comments on commit 0bd853b

Please sign in to comment.