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

34.1 breaking change #2154

Closed
Thutmose3 opened this issue Jan 22, 2025 · 7 comments · Fixed by #2155
Closed

34.1 breaking change #2154

Thutmose3 opened this issue Jan 22, 2025 · 7 comments · Fixed by #2155

Comments

@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 before

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

@fcurella
Copy link
Collaborator

Released a fix in v43.0.2

@moyoakala
Copy link

Released a fix in v43.0.2

I still get this error in v34.0.2

    raise ValueError("empty range for _rand_seconds: start datetime must be before than end datetime")
ValueError: empty range for _rand_seconds: start datetime must be before than end datetime
class BaseFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Some_Model

    date = factory.Faker(
        "past_date",
        start_date=datetime.datetime(1980, 1, 1, tzinfo=datetime.UTC),
    )

@davidefortunatotecnos
Copy link

I confirm i still get error in 34.0.2, in addition i have another error when using faker.date():

File "C:\xxx\xxx\venv\Lib\site-packages\faker\providers\date_time_init_.py", line 2084, in date
return self.date_time(end_datetime=end_datetime).strftime(pattern)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\xxx\xxx\venv\Lib\site-packages\faker\providers\date_time_init_.py", line 2023, in date_time
return self.date_time_between(start.timestamp(), end, tzinfo)
^^^^^^^^^^^^^^^^^
OSError: [Errno 22] Invalid argument

I am using Faker 34.0.2, Python 3.11.6, Windows 11

@fcurella
Copy link
Collaborator

@davidefortunatotecnos Could you show how you are calling Faker?

@fcurella
Copy link
Collaborator

@moyoakala Could you open a separate issue?

@moyoakala
Copy link

@moyoakala Could you open a separate issue?

Sure: 2156

@fcurella
Copy link
Collaborator

Changes have been reverted in v35.0.0

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 a pull request may close this issue.

4 participants