Skip to content

Commit

Permalink
update mistune to more recent version (#619)
Browse files Browse the repository at this point in the history
* gitignore ./mypy_cache, .coverage, coverage.xml,pydocstyle_report.txt
* fix mypy-stubs for mistune
* use mypy.ini to share enable_recursive_aliases between mypy and mypyc calls
* split pyproject.toml build-system requirements multi-line for better readability
* add mistune pre-hook to handle problematic markdown lists (relates to lepture/mistune#296)
* add tests for expected schema-salad-doc output
* add make utilities to compute new hash and check html diff
* fix missing newline in code sample & update metaschema-pre.yml with extra newline
* align mismatchign mypy-requirements.txt / pyproject.toml mypy version
* normalize use of get_data() in tests

Co-authored-by: Michael R. Crusoe <1330696+mr-c@users.noreply.github.com>
  • Loading branch information
fmigneault and mr-c committed Dec 9, 2022
1 parent 567665f commit 4733227
Show file tree
Hide file tree
Showing 26 changed files with 1,052 additions and 224 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.coverage
coverage.xml
pydocstyle_report.txt
.tox/
.eggs/
.vscode/
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
.eggs
*.egg-info/
*pyc
*.so

build/
dist/
mypy-stubs/ruamel/yaml
# virtualenv
# virtualenv
venv/
.cache/
.mypy_cache/
.pytest_cache/
.coverage
coverage.xml
pydocstyle_report.txt

# PyCharm
.idea/
Expand Down
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,23 @@ mypy_3.6: $(filter-out setup.py,$(PYSOURCES))
mypyc: $(PYSOURCES)
MYPYPATH=mypy-stubs SCHEMA_SALAD_USE_MYPYC=1 python setup.py test

mypyi:
MYPYPATH=mypy-stubs SCHEMA_SALAD_USE_MYPYC=1 python setup.py install

check-metaschema-diff:
docker run \
-v "$(realpath ${MODULE}/metaschema/):/tmp/:ro" \
"quay.io/commonwl/cwltool_module:latest" \
schema-salad-doc /tmp/metaschema.yml \
> /tmp/metaschema.orig.html
schema-salad-doc \
"$(realpath ${MODULE}/metaschema/metaschema.yml)" \
> /tmp/metaschema.new.html
diff -a --color /tmp/metaschema.orig.html /tmp/metaschema.new.html || true

compute-metaschema-hash:
@python -c 'import hashlib; from schema_salad.tests.test_makedoc import generate_doc; hasher = hashlib.sha256(); hasher.update(generate_doc().encode("utf-8")); print(hasher.hexdigest());'

shellcheck: FORCE
shellcheck build-schema_salad-docker.sh release-test.sh

Expand Down
197 changes: 0 additions & 197 deletions mypy-stubs/mistune.pyi

This file was deleted.

28 changes: 28 additions & 0 deletions mypy-stubs/mistune/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from typing import Iterable, Optional, Union

from mistune._types import *
from mistune.inline_parser import RendererT
from mistune.markdown import Markdown, ParseHook, RenderHook
from mistune.plugins import Plugin, PluginName
from mistune.renderers import BaseRenderer, DataT, HTMLRenderer, HTMLType
from typing_extensions import Literal

html: Markdown[HTMLType, HTMLRenderer]

RendererRef = Union[Literal["html", "ast"], BaseRenderer[DataT]]
PluginRef = Union[PluginName, Plugin] # reference to register a plugin

def create_markdown(
escape: bool = False,
hard_wrap: bool = False,
renderer: Optional[RendererRef[DataT]] = None,
plugins: Optional[Iterable[PluginRef]] = None,
) -> Markdown[DataT, RendererT]: ...
def markdown(
text: str,
escape: bool = True,
renderer: Optional[BaseRenderer[DataT]] = None,
plugins: Optional[Iterable[PluginRef]] = None,
) -> str: ...

__version__: str
5 changes: 5 additions & 0 deletions mypy-stubs/mistune/_types.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from typing import Any, Dict, List

# type aliases shared across modules
State = Dict[str, Any] # extra options that work with a given 'ParsedType'
Tokens = List[str]
Loading

0 comments on commit 4733227

Please sign in to comment.