Skip to content

Commit

Permalink
Use old-style type unions
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleFromNVIDIA committed May 3, 2024
1 parent 8baccc7 commit d8f5f17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions rapids_build_backend/config.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# Copyright (c) 2024, NVIDIA CORPORATION.

import os
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Union

from .utils import _get_pyproject

if TYPE_CHECKING:
from typing import Callable

# config options can be one of these types...
config_val_type = str | bool | None
config_val_type = Union[str, bool, None]

# ... or a callable that returns one of those or some other mutable types
mutable_config_val_type = list[str]
config_val_callable = Callable[[], config_val_type | mutable_config_val_type]
config_val_callable = Callable[[], Union[config_val_type, mutable_config_val_type]]

config_options_type = dict[str, tuple[config_val_type | config_val_callable, bool]]
config_options_type = dict[
str, tuple[Union[config_val_type, config_val_callable], bool]
]


class Config:
Expand Down
3 changes: 2 additions & 1 deletion rapids_build_backend/impls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from contextlib import contextmanager
from functools import lru_cache
from importlib import import_module
from typing import Union

import rapids_dependency_file_generator
import tomli_w
Expand Down Expand Up @@ -99,7 +100,7 @@ def _get_cuda_suffix(require_cuda=False) -> str:


@lru_cache
def _get_git_commit() -> str | None:
def _get_git_commit() -> Union[str, None]:
"""Get the current git commit.
Returns None if git is not in the PATH or if it fails to find the commit.
Expand Down

0 comments on commit d8f5f17

Please sign in to comment.