pytoolz / toolz

A functional standard library for Python.
http://toolz.readthedocs.org/
Other
4.57k stars 258 forks source link

'from tlz import curry' fails: ImportError: tlz.curry #573

Open yurivict opened 5 months ago

yurivict commented 5 months ago
$ python3.9
Python 3.9.18 (main, Dec 10 2023, 01:22:40) 
[Clang 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1 on freebsd14
Type "help", "copyright", "credits" or "license" for more information.
>>> from tlz import curry
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/tlz/_build_tlz.py", line 55, in exec_module
    toolz_mods = self._load_toolz(module.__name__)
  File "/usr/local/lib/python3.9/site-packages/tlz/_build_tlz.py", line 29, in _load_toolz
    raise ImportError(fullname)
ImportError: tlz.curry
>>>

One test, toolz/tests/test_tlz.py::test_tlz, fails with the same error:

_________________________________________________________________________________________ test_tlz __________________________________________________________________________________________

    def test_tlz():
        import tlz
>       tlz.curry
E       AttributeError: module 'tlz' has no attribute 'curry'

toolz/tests/test_tlz.py:6: AttributeError
=============================================================================== 1 failed, 179 passed in 2.59s ===============================================================================

import_module('toolz.curry') fails with: No module named 'toolz.curry'.

from toolz import curry succeeds.

Version: 0.12.0 Python-3.9 FreeBSD 14.0

yurivict commented 5 months ago

0.12.1 has 2 failures:

========================================================================================= FAILURES ==========================================================================================
______________________________________________________________________________ test_introspect_builtin_modules ______________________________________________________________________________

    def test_introspect_builtin_modules():
        mods = [builtins, functools, itertools, operator, toolz,
                toolz.functoolz, toolz.itertoolz, toolz.dicttoolz, toolz.recipes]

        denylist = set()

        def add_denylist(mod, attr):
            if hasattr(mod, attr):
                denylist.add(getattr(mod, attr))

        add_denylist(builtins, 'basestring')
        add_denylist(builtins, 'NoneType')
        add_denylist(builtins, '__metaclass__')
        add_denylist(builtins, 'sequenceiterator')

        def is_missing(modname, name, func):
            if name.startswith('_') and not name.startswith('__'):
                return False
            if name.startswith('__pyx_unpickle_') or name.endswith('_cython__'):
                return False
            try:
                if issubclass(func, BaseException):
                    return False
            except TypeError:
                pass
            try:
                return (callable(func)
                        and func.__module__ is not None
                        and modname in func.__module__
                        and is_partial_args(func, (), {}) is not True
                        and func not in denylist)
            except AttributeError:
                return False

        missing = {}
        for mod in mods:
            modname = mod.__name__
            for name, func in vars(mod).items():
                if is_missing(modname, name, func):
                    if modname not in missing:
                        missing[modname] = []
                    missing[modname].append(name)
        if missing:
            messages = []
            for modname, names in sorted(missing.items()):
                msg = '{}:\n    {}'.format(modname, '\n    '.join(sorted(names)))
                messages.append(msg)
            message = 'Missing introspection for the following callables:\n\n'
>           raise AssertionError(message + '\n\n'.join(messages))
E           AssertionError: Missing introspection for the following callables:
E           
E           builtins:
E               __orig_import__

toolz/tests/test_inspect_args.py:433: AssertionError
_________________________________________________________________________________________ test_tlz __________________________________________________________________________________________

    def test_tlz():
        import tlz
>       tlz.curry
E       AttributeError: module 'tlz' has no attribute 'curry'

toolz/tests/test_tlz.py:6: AttributeError
=============================================================================== 2 failed, 178 passed in 2.23s ===============================================================================
*** Error code 1
thisisamardeep commented 4 months ago

I could not reproduce this issue on 0.12.0 on 3.9. Just to be clear you mean the tag 0.12.0 correct ?

yurivict commented 4 months ago

Just to be clear you mean the tag 0.12.0 correct ?

Yes.

thisisamardeep commented 4 months ago

Are you able to reproduce it ?