Replace typing-extensions Literal with the type of the Literal & run mypy, nosetest and sphinx in there own environment on cicd (#677)

* Improve tox.ini by running flake8, mypy, nosetests and sphinx in there own environment.

Improves isolation. Dependencies of one package won't influence the next.

This should fail for the current setup with typing-extensions.

* Try to fix actually running tox tests on travis

* Use recent tox

* Fix using Literal[False] for open_filename.

None has the same true value as False, and therefore it does not matter.

* Replace typing_extensions.Literal by the type of the literal

* Add line to CHANGELOG.md
pull/681/head
Pieter Marsman 2021-10-12 20:22:58 +02:00 committed by GitHub
parent 9406040d8e
commit 104883df41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 13 deletions

View File

@ -6,6 +6,6 @@ python:
- "3.8" - "3.8"
- "3.9" - "3.9"
install: install:
- pip install tox==3.14.0 tox-travis flake8 - pip install tox tox-travis
script: script:
- tox -r - tox -r

View File

@ -28,6 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Support for Python 3.4 and 3.5 ([#522](https://github.com/pdfminer/pdfminer.six/pull/522)) - Support for Python 3.4 and 3.5 ([#522](https://github.com/pdfminer/pdfminer.six/pull/522))
- Unused dependency on `sortedcontainers` package ([#525](https://github.com/pdfminer/pdfminer.six/pull/525)) - Unused dependency on `sortedcontainers` package ([#525](https://github.com/pdfminer/pdfminer.six/pull/525))
- Support for non-standard output streams that are not binary ([#523](https://github.com/pdfminer/pdfminer.six/pull/523)) - Support for non-standard output streams that are not binary ([#523](https://github.com/pdfminer/pdfminer.six/pull/523))
- Dependency on typing-extensions introduced by [#661](https://github.com/pdfminer/pdfminer.six/pull/661) ([#677](https://github.com/pdfminer/pdfminer.six/pull/677))
## [20201018] ## [20201018]

View File

@ -7,7 +7,6 @@ import struct
from typing import (Any, BinaryIO, Callable, Dict, Generic, Iterable, Iterator, from typing import (Any, BinaryIO, Callable, Dict, Generic, Iterable, Iterator,
List, Optional, Set, TextIO, Tuple, TypeVar, Union, List, Optional, Set, TextIO, Tuple, TypeVar, Union,
TYPE_CHECKING, cast) TYPE_CHECKING, cast)
from typing_extensions import Literal
from html import escape from html import escape
if TYPE_CHECKING: if TYPE_CHECKING:
@ -55,10 +54,10 @@ class open_filename(object):
exc_type: object, exc_type: object,
exc_val: object, exc_val: object,
exc_tb: object exc_tb: object
) -> Literal[False]: ) -> None:
if self.closing: if self.closing:
self.file_handler.close() self.file_handler.close()
return False return
def make_compat_bytes(in_str: str) -> bytes: def make_compat_bytes(in_str: str) -> bytes:

View File

@ -5,7 +5,6 @@ import argparse
import logging import logging
import sys import sys
from typing import Any, Container, Iterable, List, Optional, Union from typing import Any, Container, Iterable, List, Optional, Union
from typing_extensions import Literal
import pdfminer.high_level import pdfminer.high_level
from pdfminer.layout import LAParams from pdfminer.layout import LAParams
@ -18,7 +17,7 @@ OUTPUT_TYPES = ((".htm", "html"),
(".xml", "xml"), (".xml", "xml"),
(".tag", "tag")) (".tag", "tag"))
FloatOrDisabled = Union[float, Literal["disabled"]] FloatOrDisabled = Union[float, str] # Union[float, Literal["disabled"]]
def float_or_disabled(x: str) -> FloatOrDisabled: def float_or_disabled(x: str) -> FloatOrDisabled:

32
tox.ini
View File

@ -1,15 +1,33 @@
[tox] [tox]
envlist = py{36,37,38,3.9} envlist = py{36,37,38,39}-{nose,flake8,mypy,docs}
[testenv] [testenv:py{36,37,38,39}-nose]
extras = deps =
dev nose
docs allowlist_externals =
whitelist_externals = nosetests
commands =
nosetests --nologcapture
[testenv:py{36,37,38,39}-flake8]
deps =
flake8
allowlist_externals =
flake8 flake8
commands = commands =
flake8 pdfminer/ tools/ tests/ --count --statistics flake8 pdfminer/ tools/ tests/ --count --statistics
[testenv:py{36,37,38,39}-mypy]
deps =
mypy
allowlist_externals =
mypy
commands =
mypy --install-types --non-interactive --show-error-codes . mypy --install-types --non-interactive --show-error-codes .
nosetests --nologcapture
[testenv:py{36,37,38,39}-docs]
extras =
docs
commands =
python -m sphinx -b html docs/source docs/build/html python -m sphinx -b html docs/source docs/build/html
python -m sphinx -b doctest docs/source docs/build/doctest python -m sphinx -b doctest docs/source docs/build/doctest