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

Faker 34.0 is breaking change #2152

Closed
sww314 opened this issue Jan 22, 2025 · 6 comments
Closed

Faker 34.0 is breaking change #2152

sww314 opened this issue Jan 22, 2025 · 6 comments

Comments

@sww314
Copy link

sww314 commented Jan 22, 2025

Our build/tests broke when upgrading from 33.1 to 34. There was nothing in the release note that indicated the change in behavior was intentional.

This is field that causes the test failure:

manufactured_on = factory.Faker("date_between", start_date="-30y", end_date="today")

Logs from out test:

Step #8 - "test": 
Step #8 - "test": cls = <class 'faker.providers.date_time.en_US.Provider'>, value = 'today'
Step #8 - "test": 
Step #8 - "test":     @classmethod
Step #8 - "test":     def _parse_date_string(cls, value: str) -> Dict[str, float]:
Step #8 - "test":         parts = cls.regex.match(value)
Step #8 - "test":         if not parts:
Step #8 - "test":             raise ParseError(f"Can't parse date string `{value}`")
Step #8 - "test":         parts = parts.groupdict()
Step #8 - "test":         time_params: Dict[str, float] = {}
Step #8 - "test":         for name_, param_ in parts.items():
Step #8 - "test":             if param_:
Step #8 - "test":                 time_params[name_] = int(param_)
Step #8 - "test":     
Step #8 - "test":         if "years" in time_params:
Step #8 - "test":             if "days" not in time_params:
Step #8 - "test":                 time_params["days"] = 0
Step #8 - "test":             time_params["days"] += 365.24 * time_params.pop("years")
Step #8 - "test":         if "months" in time_params:
Step #8 - "test":             if "days" not in time_params:
Step #8 - "test":                 time_params["days"] = 0
Step #8 - "test":             time_params["days"] += 30.42 * time_params.pop("months")
Step #8 - "test":     
Step #8 - "test":         if not time_params:
Step #8 - "test": >           raise ParseError(f"Can't parse date string `{value}`")
Step #8 - "test": E           faker.providers.date_time.ParseError: Can't parse date string `today`
Step #8 - "test": 
Step #8 - "test": /usr/local/lib/python3.12/site-packages/faker/providers/date_time/__init__.py:1924: ParseError
Repository owner deleted a comment Jan 22, 2025
@fcurella
Copy link
Collaborator

No, this was not intentional. I'm working on a fix at #2153

@fcurella
Copy link
Collaborator

I've just released a fix as v34.0.1

@Thutmose3
Copy link

For me this started breaking when using v34.0.1

self = <faker.providers.date_time.en_US.Provider object at 0x7f55c5ecf210>
start_datetime = 0, end_datetime = -604800

    def _rand_seconds(self, start_datetime: int, end_datetime: int) -> float:
        if start_datetime > end_datetime:
>           raise ValueError("empty range for _rand_seconds: start datetime must be before than end datetime")
E           ValueError: empty range for _rand_seconds: start datetime must be before than end datetime

Not sure if my code is wrong or something, but all was working fine

@Thutmose3
Copy link

This is what is failing i think:
deadline = factory.Faker("date_time", end_datetime="-1w", tzinfo=timezone.get_current_timezone())

@fcurella
Copy link
Collaborator

@Thutmose3 would you open a separate issue?

@Thutmose3
Copy link

#2154

@fcurella fcurella closed this as completed Feb 5, 2025
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

No branches or pull requests

3 participants