databricks-sdk-py
databricks-sdk-py copied to clipboard
[ISSUE] Lots of missing `Optional`s in the type hinting
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 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: https://github.com/python/mypy/issues/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.
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.
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.
This seems reasonable to me, especially as this seems to be the direction that mypy and the ecosystem are moving towards.
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.