Skip to content

deterministic @main return type#50

Merged
jorenham merged 3 commits intomainfrom
deterministic-main-return-type
Sep 20, 2024
Merged

deterministic @main return type#50
jorenham merged 3 commits intomainfrom
deterministic-main-return-type

Conversation

@jorenham
Copy link
Copy Markdown
Owner

@jorenham jorenham commented Sep 19, 2024

fixes #46

Instead of returning an over-engineered function wrapper, I decided to follow the advice of @KotlinIsland and simply return the original function directly, as the result of the main function doesn't matter anyway.

As a consequence of the cleaner code, the typing_extensions dependency isn't needed anymore, so I removed it from the required dependencies for python < 3.11.

Copy link
Copy Markdown
Collaborator

@KotlinIsland KotlinIsland left a comment

Choose a reason for hiding this comment

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

is typing_extensions a dev dependency because they are used in tests? I would try to take steps to ensure that it's never used within src code, perhaps configure ruffs TID251 rule?

edit:
oh, ermmmm idk how I feel about type importing something that isn't a dependency when it could be, seems a bit sus imo

@jorenham
Copy link
Copy Markdown
Owner Author

in theory (and in typing stubs), typing_extensions can always be used when type-checking, because typeshed includes the stubs for typing_extensions in the stdlib stubs.

@jorenham
Copy link
Copy Markdown
Owner Author

numpy uses this "trick" quite a lot btw

@jorenham
Copy link
Copy Markdown
Owner Author

oh and TID251 is already enabled

@KotlinIsland
Copy link
Copy Markdown
Collaborator

up to you, I would just include it but w/e

not sure how you would ensure that it's never imported for real in src code though

@jorenham
Copy link
Copy Markdown
Owner Author

not sure how you would ensure that it's never imported for real in src code though

My hope is that either ruff or basedpyright will catch it.
And just to be safe, I'll be including basedmypy as well; I've heard some great things about it 😉

@jorenham jorenham merged commit ee7850c into main Sep 20, 2024
@jorenham jorenham deleted the deterministic-main-return-type branch September 20, 2024 00:20
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.

Deterministic @main return type

2 participants