Repository: beartype/beartype

Issue #261: [Feature Request] Official FreeBSD support
Created: 2023-07-22T18:10:06Z
=================================== FAILURES ===================================
_____________________________ test_coerce_hint_any _____________________________

    def test_coerce_hint_any() -> None:
        '''
        Test the private
        :func:`beartype._check.convert.convcoerce.coerce_hint_any` coercer.
        '''
    
        # ..................{ IMPORTS                            }..................
        # Defer test-specific imports.
        from beartype._check.convert.convcoerce import coerce_hint_any
        from beartype._util.py.utilpyversion import (
            IS_PYTHON_AT_LEAST_3_10,
            IS_PYTHON_AT_LEAST_3_9,
        )
    
        # ..................{ CORE                               }..................
        # Assert this coercer preserves an isinstanceable type as is.
        assert coerce_hint_any(int) is int
    
        # ..................{ PEP 585                            }..................
        # If the active Python interpreter targets Python >= 3.9 and thus supports
        # PEP 585...
        if IS_PYTHON_AT_LEAST_3_9:
            # Arbitrary PEP 585-compliant type hint.
            hint_pep585 = list[int]
   
            # Assert this coercer preserves the first passed instance of a PEP
            # 585-compliant type hint as is.
>           assert coerce_hint_any(hint_pep585) is hint_pep585
E           assert list[int] is list[int]
E            +  where list[int] = <function coerce_hint_any at 0x9712688b0>(list[int])

beartype_test/a00_unit/a60_check/a20_conv/test_convcoerce.py:92: AssertionError
=========================== short test summary info ============================
SKIPPED [1] beartype_test/a90_func/z90_lib/a90_nuitka/test_nuitka.py:31: Command "gcc" not found.
SKIPPED [1] beartype_test/a00_unit/a70_decor/a40_code/a90_pep/test_decorpep647.py:21: Python 3.9.17 < 3.10.0.
SKIPPED [1] beartype_test/a00_unit/a70_decor/a40_code/a00_mod/test_decor_contextlib.py:21: Python 3.9.17 < 3.11.0.
SKIPPED [1] beartype_test/a00_unit/a70_decor/a40_code/a90_pep/test_decorpep673.py:21: Python 3.9.17 < 3.11.0.
SKIPPED [1] beartype_test/a00_unit/a70_decor/a40_code/a80_nonpep/mod/test_codepandera.py:22: could not import 'pandera.__init__': No module named 'pandera'
SKIPPED [1] beartype_test/a90_func/pep/test_pep561_static.py:169: Command "pyright" not found.
================== 1 failed, 288 passed, 6 skipped in 31.12s ===================
*** Error code 1



Version: 0.15.0
Python-3.9
FreeBSD 13.2

Duplicate issue #497: The test test_door_is_bearable_warnings fails
Created: 2025-02-22T08:56:16Z
______________________________________________________________________________________________________________________________ test_door_is_bearable_warnings _______________________________________________________________________________________________________________________________

hints_meta = (HintPepMetadata(
    hint=typing.Any,
    conf=BeartypeConf(),
    pep_sign=HintSign('Any'),
    typehint_cls=None,
 ...gexes=('\\btype hint\\b',),
    exception_str_not_match_regexes=(),
)),
    typevars=(),
    warning_type=None,
), ...)

    def test_door_is_bearable_warnings(hints_meta) -> None:
        '''
        Test the :class:`beartype.door.is_bearable` tester function with respect
        to non-fatal warnings emitted by that tester when passed various problematic
        (e.g., deprecated) type hints.
    
        Note that this test *cannot* be folded into the comparable
        :func:`.test_door_is_bearable` test. Why? Because that test (and almost all
        other tests testing type hints) iterates over type hints by calling the
        session-scoped ``iter_hints_piths_meta()`` closure iterator. For unknown
        reasons, :mod:`pytest` fails to capture deprecation warnings emitted from
        that iterator. This is almost certainly a :mod:`pytest` issue. However,
        reporting this issue would require reducing this issue to a minimal
        reproducible working example -- which appears to be infeasible. In short,
        this test manually iterates over type hints as an acceptable (albeit
        annoying) alternative that allows deprecation warnings to be captured.
    
        Parameters
        ----------
        hints_meta : List[beartype_test.a00_unit.data.hint.util.data_hintmetacls.HintNonpepMetadata]
            List of PEP-agnostic type hint metadata describing sample PEP-agnostic
            type hints exercising edge cases in the :mod:`beartype` codebase.
        '''
    
        # ..................{ IMPORTS                            }..................
        # Defer test-specific imports.
        from beartype.door import is_bearable
        from pytest import warns
        from warnings import simplefilter
    
        # ....................{ SETUP                          }....................
        # Force pytest to temporarily allow deprecation warnings to be caught by the
        # warns() context manager for the duration of this test. By default, pytest
        # simply "passes through" all deprecation warnings for subsequent reporting
        # if tests otherwise successfully pass. Deprecation warnings include:
        # * "DeprecationWarning".
        # * "FutureWarning".
        # * "PendingDeprecationWarning".
        simplefilter('always')
    
        # ..................{ PASS                               }..................
        # For each predefined type hint and associated metadata...
        for hint_meta in hints_meta:
            # If it is *NOT* the case that...
            if not (
                # This hint is currently supported *AND*...
                hint_meta.is_supported and
                # This is type-checkable against at least one object.
                hint_meta.piths_meta
            # Then this hint is ignorable. Silently continue to the next.
            ):
                continue
            # Else, this hint is currently supported.
    
            # Type hint to be type-checked.
            hint = hint_meta.hint
    
            # Beartype dataclass configuring this type-check.
            conf = hint_meta.conf
    
            # Object to be type-checked against this hint, arbitrarily selected from
            # the iterable of all such objects supplied with this hint. By the above
            # validation, this is guaranteed to be non-empty.
            pith = hint_meta.piths_meta[0]
    
            # If this tester is expected to emit a warning for this hint...
            if hint_meta.warning_type is not None:
                # print(f'hint_meta: {hint_meta}\n')
    
                # Call this tester under a context manager asserting this tester to
                # emit the expected warning.
>               with warns(hint_meta.warning_type):
E               Failed: DID NOT WARN. No warnings of type (<class 'beartype.roar.BeartypeDecorHintPep585DeprecationWarning'>,) were emitted.
E                Emitted warnings: [].

beartype_test/a00_unit/a60_check/a90_door/test_checkdoor.py:119: Failed

Version: 0.20.0
Python-3.11
FreeBSD 14.2

Closing comment (2025-02-22T17:40:46Z): lolbro. Good Ol' FreeBSD, eh? In theory, @beartype continues to love us some *BSD. In practice, @beartype still lacks official *BSD support. This issue is thus a duplicate of #261, which has been around since before the dawn of Guido.
Please, somebody. Submit a PR improving *BSD support. Until then, emoji cat regretfully closes this duplicate issue. 😿