-
Notifications
You must be signed in to change notification settings - Fork 586
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
st.datetimes(allow_imaginary=False) can raise internal error
#2662
Comments
|
To work around this issue I'm using: dates = st.datetimes(
min_value=datetime.datetime(2000, 1, 1),
max_value=datetime.datetime(9000, 12, 31),
timezones=st.just(datetime.timezone.utc),
allow_imaginary=False,
).map(lambda d: d.replace(tzinfo=None, fold=0)) |
|
Thanks for reporting this! I think our fix is probably to disallow Unfortunately your workaround still permits the generation of imaginary times - while UTC has no imaginary times, replacing UTC with your local timezone may create one. Instead, use: dates = st.datetimes(
min_value=datetime.datetime(2000, 1, 1),
max_value=datetime.datetime(9000, 12, 31),
timezones=st.just(datetime.timezone.utc),
).map(lambda d: d.astimezone(tz=None)) |
|
There's no such thing as an imaginary datetime with dates = st.datetimes(
min_value=datetime.datetime(2000, 1, 1), max_value=datetime.datetime(9000, 12, 31)
)More generally, if your datetime objects represent a time in UTC I would strongly recommend using |
|
Thank a lot. I'm still wrapping my head around the imaginary datetime stuff. Unfortunately, I cannot use Best regards, |
|
Well... I'd try to use |
st.datetimes(allow_imaginary=False) can raise internal error
strategies.datetimemay raise such an error when passedallow_imaginary=Falseand tzinfo is None.I have the following:
The error looks like (pytest style):
Notice that
value.tzinfois None, soastimezoneuses the local timezone.The text was updated successfully, but these errors were encountered: