Skip to content

Commit

Permalink
Pyright testing x 4.
Browse files Browse the repository at this point in the history
This commit is the *real* last in a commit chain enforcing static
type-checking with `pyright` via our existing `pytest`-driven test
suite. Specifically, this commit augments the `test_pep561_pyright`
functional test conditionally statically type-checking the @beartype
codebase against the external `pyright` command in the current `${PATH}`
(if available) to additionally perform checks specific to the current
version of the active Python interpreter that is being tested. Let this
demon finally die! (*Oodles of noodles!*)
  • Loading branch information
leycec committed Jul 2, 2022
1 parent fe91023 commit a23d0d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
18 changes: 9 additions & 9 deletions beartype_test/a00_unit/a20_util/func/test_utilfuncmake.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# --------------------( LICENSE )--------------------
# --------------------( LICENSE )--------------------
# Copyright (c) 2014-2022 Beartype authors.
# See "LICENSE" for further details.

Expand All @@ -10,18 +10,17 @@
:mod:`beartype._util.utilfunc.utilfuncmake` submodule.
'''

# ....................{ IMPORTS }....................
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# ....................{ IMPORTS }....................
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# WARNING: To raise human-readable test errors, avoid importing from
# package-specific submodules at module scope.
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
from pytest import raises
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

# ....................{ GLOBALS }....................
# ....................{ GLOBALS }....................
# Arbitrary global referenced in functions created below.
AND_SEE_THE_GREAT_ACHILLES = 'whom we knew'

# ....................{ TESTS ~ make }....................
# ....................{ TESTS ~ make }....................
#FIXME: Consider excising. Although awesome, this is no longer needed.
# def test_copy_func_shallow_pass() -> None:
# '''
Expand Down Expand Up @@ -103,7 +102,7 @@
# copy_func_shallow(
# func=iter, exception_cls=BeartypeDecorWrapperException)

# ....................{ TESTS ~ make }....................
# ....................{ TESTS ~ make }....................
def test_make_func_pass(capsys) -> None:
'''
Test successful usage of the
Expand All @@ -123,8 +122,8 @@ def test_make_func_pass(capsys) -> None:

# Defer heavyweight imports.
from beartype._util.func.utilfuncmake import make_func
from beartype.typing import Optional
from linecache import cache as linecache_cache
from typing import Optional

# Arbitrary local referenced in functions created below.
THO_MUCH_IS_TAKEN = 'much abides; and tho’'
Expand Down Expand Up @@ -225,6 +224,7 @@ def test_make_func_fail() -> None:
from beartype.roar import BeartypeDecorWrapperException
from beartype.roar._roarexc import _BeartypeUtilCallableException
from beartype._util.func.utilfuncmake import make_func
from pytest import raises

# Assert that attempting to create a function whose name collides with that
# of a caller-defined local variable raises the expected exception.
Expand Down
9 changes: 2 additions & 7 deletions beartype_test/a90_func/pep/test_pep561_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ def test_pep561_pyright() -> None:

# Defer heavyweight imports.
from beartype.meta import PACKAGE_NAME
# from beartype._util.py.utilpyversion import get_python_version_major_minor
# from beartype_test.util.path.pytpathmain import get_main_package_dir
from beartype._util.py.utilpyversion import get_python_version_major_minor
from beartype_test.util.cmd.pytcmdrun import run_command_forward_output

# List of all shell words with which to run the external "pyright" command.
Expand All @@ -186,13 +185,9 @@ def test_pep561_pyright() -> None:
#so until someone explicitly requests we do so, please. This has dragged
#on long enough, people!

#FIXME: *YIKES.* "pyright" raises an extreme number of unexpected errors
#when passing this option, which is horrifying. See "This has dragged
#on long enough, people!", above. For now, let's just redundantly run
#"pyright" against its default Python version -- whatever that is. Gah!
# # Major and minor version of the active Python interpreter, ignoring the
# # patch version of this interpreter.
# '--pythonversion', get_python_version_major_minor(),
'--pythonversion', get_python_version_major_minor(),

# Relative basename of this project's top-level package. Ideally, the
# absolute dirname of this package would instead be passed as:
Expand Down

0 comments on commit a23d0d8

Please sign in to comment.