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

[ISSUE] Lots of missing Optionals in the type hinting #564

Open
judahrand opened this issue Feb 26, 2024 · 5 comments · May be fixed by #565
Open

[ISSUE] Lots of missing Optionals in the type hinting #564

judahrand opened this issue Feb 26, 2024 · 5 comments · May be fixed by #565

Comments

@judahrand
Copy link
Contributor

Description

In lots of places the SDK's type hints look like:

foo: str = None

This typing is incorrect and should be:

foo: str | None = None
@judahrand judahrand changed the title [ISSUE] Lots of missing Optionals in the type hinting [ISSUE] Lots of missing Optionals in the type hinting of WorkspaceClient Feb 26, 2024
@judahrand judahrand linked a pull request Feb 26, 2024 that will close this issue
3 tasks
@PeterJCLaw
Copy link

PeterJCLaw commented Feb 26, 2024

@judahrand are you aware of mypy's --implicit-optional behaviour? The foo: str = None style is valid when using that option. (I don't know if other checkers have a similar behaviour, though it's likely they do)

I appreciate that not everyone uses that style (and I would personally discourage library authors from doing so as being explicit is usually clearer), however my understanding is that the spelling used in this project shouldn't impact how your project is type-checked. If it does, that may be a bug (e.g: python/mypy#9208) in your type checker and/or you may need to configure handling of implicit optionals if it's intentional that this project uses that style.

@mgyucht
Copy link
Contributor

mgyucht commented Feb 26, 2024

To be honest, this project doesn't make use of mypy typechecking quite yet. We've been meaning to add support for it, and I think we'd be open to discussion about whether enabling --implicit-optional is preferable or not for this project.

@judahrand
Copy link
Contributor Author

I think that using explicit Optional is probably preferable given that not using it requires downstream consumers to have to configure their type checker correctly vs just using the defaults.

@mgyucht
Copy link
Contributor

mgyucht commented Feb 26, 2024

This seems reasonable to me, especially as this seems to be the direction that mypy and the ecosystem are moving towards.

@judahrand
Copy link
Contributor Author

judahrand commented Feb 26, 2024

This seems reasonable to me, especially as this seems to be the direction that mypy and the ecosystem are moving towards.

This might not be the right place to raise this but it would be nice if this could be changed/updated in databricks-connect too. I'd open a PR but unfortunately the source isn't available anywhere other that PyPi.

@judahrand judahrand changed the title [ISSUE] Lots of missing Optionals in the type hinting of WorkspaceClient [ISSUE] Lots of missing Optionals in the type hinting Feb 26, 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 a pull request may close this issue.

3 participants