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

[python] Convert from Optional[Foo] to Foo|None #3334

Closed
johnkerl opened this issue Nov 18, 2024 · 3 comments · Fixed by #3453 or single-cell-data/SOMA#252
Closed

[python] Convert from Optional[Foo] to Foo|None #3334

johnkerl opened this issue Nov 18, 2024 · 3 comments · Fixed by #3453 or single-cell-data/SOMA#252
Assignees
Labels

Comments

@johnkerl
Copy link
Member

johnkerl commented Nov 18, 2024

Per feedback by @bkmartinjr on #3304:

  • Since Python 3.10, and the Google Python style guide, the type | None is recommend, and Optional is not recommended.
  • Python 3.9 supports this syntax as long as we do from __futures__ import annotations
  • Python 3.8 does not, but as of [python] Drop support for Python 3.8 (EOL 2024/10) #2141 we no longer support Python 3.8

Thus, now is a good time for us to adapt to evolving style-guide recommendations in this regard.

Also needs to be done for https://github.com/single-cell-data/SOMA

@johnkerl johnkerl changed the title [python] Convert from Optional[Foo] to Union[Foo | None] [python] Convert from Optional[Foo] to Union[Foo|None] Nov 18, 2024
@johnkerl johnkerl changed the title [python] Convert from Optional[Foo] to Union[Foo|None] [python] Convert from Optional[Foo] to Foo|None Nov 19, 2024
@johnkerl
Copy link
Member Author

Note: Bruce also points out that Union[Foo, None] is a less recent suggestion and Foo|None is the more recent suggestion.

github-actions bot pushed a commit that referenced this issue Dec 17, 2024
* [python] Convert from `Optional[Foo]` to `Foo | None`
Convert `Optional` to [union
types](https://docs.python.org/3/library/stdtypes.html#union-type)

[SC-60887](https://app.shortcut.com/tiledb-inc/story/60887)

resolves #3334

* Use union types in submodules

* Use union types in tests

* Use `Union[]` instead of `| None`

* Use union types for top-level init files
johnkerl pushed a commit that referenced this issue Dec 18, 2024
* [python] Convert from `Optional[Foo]` to `Foo | None`
Convert `Optional` to [union
types](https://docs.python.org/3/library/stdtypes.html#union-type)

[SC-60887](https://app.shortcut.com/tiledb-inc/story/60887)

resolves #3334

* Use union types in submodules

* Use union types in tests

* Use `Union[]` instead of `| None`

* Use union types for top-level init files

Co-authored-by: Paul Hoffman <[email protected]>
@johnkerl
Copy link
Member Author

@mojaveazure did you do somacore as well?

@johnkerl
Copy link
Member Author

Thanks @mojaveazure !! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants