Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functools.partial objects do not always have a __module__ attribute, … #1233

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Limfocit
Copy link

@Limfocit Limfocit commented Mar 2, 2025

Fixes #1232

When working with the latest version of the library, got an error

  1752         return plot(
   1753             results=results,
   1754             df=self._data,
   (...)
   1769             show_legend=show_legend,
   1770             open_browser=open_browser)
   1773 # NOTE: Don't put anything public below this __all__ list
   1775 __all__ = [getattr(v, '__name__', k)
   1776            for k, v in globals().items()                        # export
-> 1777            if ((callable(v) and v.__module__ == __name__ or     # callables from this module
   1778                 k.isupper()) and                                # or CONSTANTS
   1779                not getattr(v, '__name__', k).startswith('_'))]  # neither marked internal
   1781 # NOTE: Don't put anything public below here. See above.

AttributeError: 'functools.partial' object has no attribute '__module__'

The error is occurring because functools.partial objects do not always have a module attribute, but the backtesting.py library is assuming that all callable objects do.
With the suggested fix, the code started to work.

…but the backtesting.py library is assuming that all callable objects do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AttributeError: 'functools.partial' object has no attribute '__module__'
1 participant