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

Datetimes have a UTC timezone by default #601

Merged
merged 7 commits into from
Feb 4, 2022
Merged

Conversation

prescod
Copy link
Contributor

@prescod prescod commented Feb 3, 2022

Overrides Faker's DateTime-generating methods to return DateTimes with timezone set to UTC by default. Other timezones can be specified as a relativedelta. Timezone handling can be turned off by specifying False.

@prescod prescod requested a review from a team as a code owner February 3, 2022 09:51
return mockobj._index[tablename][index][field]
else: # return a full row
return mockobj._index[tablename][index]
if index is None: # return all rows
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are some improvements to the testing infrastructure to make certain kinds of assertions easier to write. It doesn't require a deep review because it isn't user-facing code and it gets well-tested by virtue of being a test suite.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔬 🕵🏾‍♂️

jstvz
jstvz previously approved these changes Feb 3, 2022
@@ -585,7 +585,11 @@ def executable_blocks(self):
return {**self.field_funcs(), "fake": self.fake}

def fake(self, name):
return str(self.runtime_context.faker_template_library._get_fake_data(name))
val = self.runtime_context.faker_template_library._get_fake_data(name)
if isinstance(val, Scalar.__args__):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use typing.get_args() here instead:

Suggested change
if isinstance(val, Scalar.__args__):
if isinstance(val, T.get_args(scalar)):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't do it exactly that way but: b622e7c

Copy link
Contributor

@jstvz jstvz Feb 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prescod Did you mean to replace this with ScalarTypes?

snowfakery/output_streams.py Outdated Show resolved Hide resolved
return mockobj._index[tablename][index][field]
else: # return a full row
return mockobj._index[tablename][index]
if index is None: # return all rows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔬 🕵🏾‍♂️

Comment on lines 131 to 132
assert "+0" in dt or dt.endswith("Z"), dt
assert dateparser.parse(dt).tzinfo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using dateparser.isoparse() instead? parse is pretty liberal about what it accepts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paul Prescod and others added 2 commits February 3, 2022 12:45
@prescod prescod requested a review from jstvz February 3, 2022 20:49
@prescod prescod enabled auto-merge (squash) February 4, 2022 01:20
@prescod prescod merged commit 6bfaba9 into main Feb 4, 2022
Copy link
Contributor

@jstvz jstvz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've got Scalar.__args__ here (if you meant to change it), but LGTM otherwise.

@prescod prescod deleted the feature/always-use-UTC branch February 4, 2022 02:08
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.

2 participants