Skip to content

Commit 0a2bd5b

Browse files
cyyevermeta-codesync[bot]
authored andcommitted
Use Python 3.10+ typing in setup and list_versions (#5847)
Summary: X-link: https://github.com/facebookresearch/FBGEMM/pull/2770 Pull Request resolved: #5847 Reviewed By: cthi Differential Revision: D107830046 Pulled By: q10 fbshipit-source-id: 5f89c81beeeb805bbe4ac6f3effa233fb12b9b88
1 parent 8ac2022 commit 0a2bd5b

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

fbgemm_gpu/list_versions/cli_run.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import logging
1111
import subprocess
1212
from datetime import datetime
13-
from typing import Union
1413

1514
import click
1615
import pandas as pd
@@ -34,7 +33,7 @@ def __init__(
3433
self._timestamp = timestamp
3534
self._visible = visible
3635

37-
def to_dict(self) -> dict[str, Union[int, str]]:
36+
def to_dict(self) -> dict[str, int | str]:
3837
return {
3938
"cli": self._cli,
4039
"stdout": self._stdout,
@@ -52,7 +51,7 @@ def __init__(self) -> None:
5251
self._cli_outputs: list[CLIOutput] = [
5352
CLIOutput(
5453
cli="python –c “import torch; print(torch.__version__)”",
55-
stdout="{}".format(torch.__version__),
54+
stdout=f"{torch.__version__}",
5655
stderr="",
5756
returncode=0,
5857
timestamp=datetime.now().isoformat(),
@@ -62,7 +61,7 @@ def __init__(self) -> None:
6261

6362
def run(
6463
self,
65-
cli: Union[str, list[str]],
64+
cli: str | list[str],
6665
visible: bool = True,
6766
input: str = "",
6867
capture_output: bool = True,

fbgemm_gpu/setup.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import textwrap
1515
from dataclasses import dataclass
1616
from datetime import date
17-
from typing import Optional
1817

1918
import setuptools
2019
import setuptools_git_versioning as gitversion
@@ -114,7 +113,7 @@ def is_fbpkg_build(self) -> bool:
114113
]
115114
)
116115

117-
def nova_flag(self) -> Optional[int]:
116+
def nova_flag(self) -> int | None:
118117
if "BUILD_FROM_NOVA" in os.environ:
119118
if str(os.getenv("BUILD_FROM_NOVA")) == "0":
120119
return 0
@@ -132,7 +131,7 @@ def nova_non_prebuild_step(self) -> bool:
132131
# flag. As such, we skip building in the clean and build wheel steps.
133132
return self.nova_flag() == 1
134133

135-
def target(self) -> Optional[str]:
134+
def target(self) -> str | None:
136135
if self.args.build_target == "none":
137136
return None
138137
return self.args.build_target
@@ -425,7 +424,7 @@ class CudaUtils:
425424
"""CUDA Utilities"""
426425

427426
@classmethod
428-
def nvcc_ok(cls, cuda_home: Optional[str], major: int, minor: int) -> bool:
427+
def nvcc_ok(cls, cuda_home: str | None, major: int, minor: int) -> bool:
429428
if not cuda_home:
430429
return False
431430

@@ -448,7 +447,7 @@ def nvcc_ok(cls, cuda_home: Optional[str], major: int, minor: int) -> bool:
448447
return result
449448

450449
@classmethod
451-
def find_cuda(cls, major: int, minor: int) -> Optional[str]:
450+
def find_cuda(cls, major: int, minor: int) -> str | None:
452451
cuda_home = os.environ.get("CUDA_BIN_PATH")
453452
if cls.nvcc_ok(cuda_home, major, minor):
454453
return cuda_home

0 commit comments

Comments
 (0)