Skip to content

Modernize type hints to use PEP 604 union syntax in balance package ( | )#157

Closed
talgalili wants to merge 1 commit intofacebookresearch:mainfrom
talgalili:export-D87614454
Closed

Modernize type hints to use PEP 604 union syntax in balance package ( | )#157
talgalili wants to merge 1 commit intofacebookresearch:mainfrom
talgalili:export-D87614454

Conversation

@talgalili
Copy link
Contributor

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

@meta-codesync
Copy link

meta-codesync bot commented Nov 21, 2025

@talgalili has exported this pull request. If you are a Meta employee, you can view the originating Diff in D87614454.

@meta-cla meta-cla bot added the cla signed label Nov 21, 2025
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
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
… | ) (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
@meta-codesync
Copy link

meta-codesync bot commented Nov 21, 2025

This pull request has been merged in 722faab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants