Modernize type hints to use PEP 604 union syntax in balance package ( | )#157
Closed
talgalili wants to merge 1 commit intofacebookresearch:mainfrom
Closed
Modernize type hints to use PEP 604 union syntax in balance package ( | )#157talgalili wants to merge 1 commit intofacebookresearch:mainfrom
talgalili wants to merge 1 commit intofacebookresearch:mainfrom
Conversation
|
@talgalili has exported this pull request. If you are a Meta employee, you can view the originating Diff in D87614454. |
talgalili
added a commit
to talgalili/balance
that referenced
this pull request
Nov 21, 2025
… | ) (facebookresearch#157) Summary: Updated type annotations across the balance package to use the newer PEP 604 union syntax (`X | Y`) instead of the older `typing.Union` and `typing.Optional` syntax. This modernization improves code readability and aligns with Python 3.10+ typing conventions. Key changes: - Replaced `Union[X, Y]` with `X | Y` - Replaced `Optional[X]` with `X | None` - Updated `from __future__ import` statements to use `annotations` instead of the older `absolute_import, division, print_function, unicode_literals` - Removed unnecessary `Union` and `Optional` imports from `typing` All changes are backward compatible with Python 3.9 as `from __future__ import annotations` enables deferred evaluation of type hints, allowing the new syntax to work properly. This modernization affects 11 files across the balance package including core modules like `adjustment.py`, `balancedf_class.py`, `sample_class.py`, and various stats and weighting methods. Differential Revision: D87614454
d9e11dc to
c6b9d92
Compare
talgalili
added a commit
to talgalili/balance
that referenced
this pull request
Nov 21, 2025
… | ) (facebookresearch#157) Summary: Updated type annotations across the balance package to use the newer PEP 604 union syntax (`X | Y`) instead of the older `typing.Union` and `typing.Optional` syntax. This modernization improves code readability and aligns with Python 3.10+ typing conventions. Key changes: - Replaced `Union[X, Y]` with `X | Y` - Replaced `Optional[X]` with `X | None` - Updated `from __future__ import` statements to use `annotations` instead of the older `absolute_import, division, print_function, unicode_literals` - Removed unnecessary `Union` and `Optional` imports from `typing` All changes are backward compatible with Python 3.9 as `from __future__ import annotations` enables deferred evaluation of type hints, allowing the new syntax to work properly. This modernization affects 11 files across the balance package including core modules like `adjustment.py`, `balancedf_class.py`, `sample_class.py`, and various stats and weighting methods. Differential Revision: D87614454
c6b9d92 to
6be6143
Compare
… | ) (facebookresearch#157) Summary: Updated type annotations across the balance package to use the newer PEP 604 union syntax (`X | Y`) instead of the older `typing.Union` and `typing.Optional` syntax. This modernization improves code readability and aligns with Python 3.10+ typing conventions. Key changes: - Replaced `Union[X, Y]` with `X | Y` - Replaced `Optional[X]` with `X | None` - Updated `from __future__ import` statements to use `annotations` instead of the older `absolute_import, division, print_function, unicode_literals` - Removed unnecessary `Union` and `Optional` imports from `typing` All changes are backward compatible with Python 3.9 as `from __future__ import annotations` enables deferred evaluation of type hints, allowing the new syntax to work properly. This modernization affects 11 files across the balance package including core modules like `adjustment.py`, `balancedf_class.py`, `sample_class.py`, and various stats and weighting methods. Differential Revision: D87614454
6be6143 to
2286e30
Compare
|
This pull request has been merged in 722faab. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Updated type annotations across the balance package to use the newer PEP 604 union syntax (
X | Y) instead of the oldertyping.Unionandtyping.Optionalsyntax. This modernization improves code readability and aligns with Python 3.10+ typing conventions.Key changes:
Union[X, Y]withX | YOptional[X]withX | Nonefrom __future__ importstatements to useannotationsinstead of the olderabsolute_import, division, print_function, unicode_literalsUnionandOptionalimports fromtypingAll changes are backward compatible with Python 3.9 as
from __future__ import annotationsenables deferred evaluation of type hints, allowing the new syntax to work properly. This modernization affects 11 files across the balance package including core modules likeadjustment.py,balancedf_class.py,sample_class.py, and various stats and weighting methods.Differential Revision: D87614454