-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added history. * Added helper for writing test Python files. * Changed the Invoke tasks to also add sources alongside the wheels * package_info test should only run locally. * Fixed incorrect error message. * Fix for Pyright that didn't like Shape and Structure. * Version bump. * Added the sources to the wheel test. * Writing some history. Co-authored-by: Ramon <p8u7wAPC5Pg9HYkkCkzA>
- Loading branch information
1 parent
14a6bba
commit 0e37975
Showing
14 changed files
with
135 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
autoflake | ||
beartype<0.10.0; python_version<'3.10' | ||
beartype>=0.10.0; python_version>='3.10' | ||
black | ||
coverage | ||
codecov>=2.1.0 | ||
feedparser | ||
isort | ||
mypy | ||
pylint | ||
pyright | ||
setuptools | ||
wheel | ||
beartype<0.10.0; python_version<'3.10' | ||
beartype>=0.10.0; python_version>='3.10' | ||
typeguard | ||
feedparser | ||
wheel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
SOFTWARE. | ||
""" | ||
__title__ = "nptyping" | ||
__version__ = "2.1.2" | ||
__version__ = "2.1.3" | ||
__author__ = "Ramon Hagenaars" | ||
__author_email__ = "[email protected]" | ||
__description__ = "Type hints for NumPy." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import contextlib | ||
import os | ||
from pathlib import Path | ||
from tempfile import TemporaryDirectory | ||
from textwrap import dedent | ||
|
||
|
||
@contextlib.contextmanager | ||
def temp_file(python_code: str, file_name: str = "test_file.py"): | ||
file_content = dedent(python_code).strip() + os.linesep | ||
with TemporaryDirectory() as directory_name: | ||
path_to_file = Path(directory_name) / file_name | ||
with open(path_to_file, "w") as file: | ||
file.write(file_content) | ||
yield path_to_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from functools import partial | ||
from subprocess import PIPE, run | ||
from typing import Tuple | ||
from unittest import TestCase | ||
|
||
import pyright | ||
|
||
from tests.test_helpers.temp_file import temp_file | ||
|
||
|
||
def _check_pyright_on_code(python_code: str) -> Tuple[int, str, str]: | ||
pyright.node.subprocess.run = partial(run, stdout=PIPE, stderr=PIPE) | ||
try: | ||
with temp_file(python_code) as path_to_file: | ||
result = pyright.run(str(path_to_file)) | ||
return ( | ||
result.returncode, | ||
bytes.decode(result.stdout), | ||
bytes.decode(result.stderr), | ||
) | ||
finally: | ||
pyright.node.subprocess.run = run | ||
|
||
|
||
class PyrightTest(TestCase): | ||
def test_pyright_accepts_array_with_shape(self): | ||
exit_code, stdout, sterr = _check_pyright_on_code( | ||
""" | ||
from typing import Any | ||
from nptyping import NDArray, Shape | ||
NDArray[Shape["*, ..."], Any] | ||
""" | ||
) | ||
self.assertEqual(0, exit_code, stdout) | ||
|
||
def test_pyright_accepts_array_with_structure(self): | ||
exit_code, stdout, sterr = _check_pyright_on_code( | ||
""" | ||
from typing import Any | ||
from nptyping import NDArray, Structure | ||
NDArray[Any, Structure["x: Int, y: Float"]] | ||
""" | ||
) | ||
self.assertEqual(0, exit_code, stdout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters