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

feat: Minor improvements to code style #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ijsbol
Copy link

@ijsbol ijsbol commented Apr 2, 2024

Hiya, I made some improvements to the typing along with updating the module to follow PEP best practices such as using __all__ in the __init__ file & not shadowing variable types on SnowflakeGenerator.__init__. Additionally, I've updated both classes to use __slots__ which improves overal performance.

Copy link
Owner

@vd2org vd2org left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution. Reviewed.

src/snowflake/snowflake.py Outdated Show resolved Hide resolved
@@ -56,7 +64,7 @@ def seconds(self) -> float:
def datetime(self) -> datetime:
return datetime.utcfromtimestamp(self.seconds)

def datetime_tz(self, tz: Optional[tzinfo] = None) -> datetime:
def datetime_tz(self, tz: Optional[tzinfo] = None) -> 'datetime':
Copy link
Owner

Choose a reason for hiding this comment

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

Why?

Copy link
Author

Choose a reason for hiding this comment

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

Raises type errors in newer Python versions.

Copy link
Owner

Choose a reason for hiding this comment

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

Hmmm... specifically?

Copy link
Owner

@vd2org vd2org Apr 3, 2024

Choose a reason for hiding this comment

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

Checked on 3.11 and 3.12. No errors there. Did I miss something?

Copy link
Author

Choose a reason for hiding this comment

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

It was raising unknown type errors when using pyright for 3.12.2

Copy link
Owner

@vd2org vd2org Apr 3, 2024

Choose a reason for hiding this comment

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

Can't reproduce it. Could you share the full example, please?

@ijsbol
Copy link
Author

ijsbol commented Apr 2, 2024

Updated for <3.10 support.

@vd2org vd2org self-assigned this Apr 7, 2024
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.

None yet

2 participants