Skip to content

Dessert fails when importing pendulum 3.0.0 #25

Description

@LiadOz

When attempting the following:

with dessert.rewrite_assertions_context():
    emport.import_file("path/to/pendulum/date.py")

dessert fails with:

  File "/Users/loz/terrible/python_ten/ten_env/lib/python3.10/site-packages/pendulum/helpers.py", line 51, in <module>
    difference_formatter = DifferenceFormatter()
  File "/Users/loz/terrible/python_ten/ten_env/lib/python3.10/site-packages/pendulum/formatting/difference_formatter.py", line 18, in __init__
    self._locale = Locale.load(locale)
  File "/Users/loz/terrible/python_ten/ten_env/lib/python3.10/site-packages/pendulum/locales/locale.py", line 41, in load
    raise ValueError(f"Locale [{locale}] does not exist.")

I bet it's related to the following code that did not exist in the previous pendulum version:

        locale_path = cast(Path, resources.files(__package__).joinpath(actual_locale))

Full context:

class Locale:

   ...

    @classmethod
    def load(cls, locale: str | Locale) -> Locale:
        if isinstance(locale, Locale):
            return locale

        locale = cls.normalize_locale(locale)
        if locale in cls._cache:
            return cls._cache[locale]

        # Checking locale existence
        actual_locale = locale
        locale_path = cast(Path, resources.files(__package__).joinpath(actual_locale))
        while not locale_path.exists():
            if actual_locale == locale:
                raise ValueError(f"Locale [{locale}] does not exist.")

EDIT: It seems that it works for python3.9 but fails in 3.10

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions