Skip to content

Simplify imports#29

Closed
ericbn wants to merge 2 commits intosvix:mainfrom
ericbn:simplify-imports
Closed

Simplify imports#29
ericbn wants to merge 2 commits intosvix:mainfrom
ericbn:simplify-imports

Conversation

@ericbn
Copy link
Copy Markdown
Contributor

@ericbn ericbn commented Oct 28, 2024

No need to re-import datetime as datetime_lib inside __init__, just import it as that in the outer scope once.
Import the typing members directly.

No need to re-import datetime as datetime_lib inside __init__, just
import it as that in the outer scope once.
Import the typing members directly.
Copy link
Copy Markdown
Member

@tasn tasn left a comment

Choose a reason for hiding this comment

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

Hey @ericbn, thanks for the contributions! These changes are unfortunately very subjective, and they are different to our stylistic choices at Svix. We follow the t for typing and prefer not to rename when importing. So the previous version is more suitable for us.

@ericbn
Copy link
Copy Markdown
Contributor Author

ericbn commented Oct 28, 2024

We follow the t for typing and prefer not to rename when importing.

Hi @tasn. I sure can revert the changes in the typing import.

Regarding not renaming, you're already doing from datetime import datetime as datetime_lib inside __init__, because the argument is called datetime. I'd argue it's simpler to do that same from datetime import datetime as datetime_lib in the main scope, instead of hiding the first datetime import with the datetime argument and then importing datetime as datetime_lib every time again inside __init__.

EDIT: Just reverted the changes to the typing import.

@svix-jbrown
Copy link
Copy Markdown
Contributor

@ericbn I don't think this is necessary any more under the current latest release; I independently made an equivalent change in #31. Sorry for the very slow turnaround!

@ericbn ericbn deleted the simplify-imports branch March 31, 2026 17:34
@ericbn
Copy link
Copy Markdown
Contributor Author

ericbn commented Mar 31, 2026

Cool, for your consideration this could be a good fit to still further refactor the existing code: https://adamj.eu/tech/2019/09/12/how-i-import-pythons-datetime-module/

It's even mentioned and suggested in https://docs.python.org/3/library/datetime.html

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.

3 participants