Skip to content

Commit

Permalink
Fixes some warnings with latest setuptools (#1445)
Browse files Browse the repository at this point in the history
Signed-off-by: Tao He <[email protected]>
  • Loading branch information
sighingnow authored Jul 3, 2023
1 parent e48b9c9 commit 6303ccb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 88
exclude = '''
Expand Down
18 changes: 15 additions & 3 deletions python/vineyard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import logging
import os
import sys
from typing import Any
from typing import Dict
from typing import Generator
from typing import Union

from .version import __version__

Expand All @@ -39,7 +43,11 @@


@contextlib.contextmanager
def envvars(key: str, value: str = None, append: bool = False) -> None:
def envvars(
key: Union[str, Dict[str, str]],
value: Union[str, None] = None,
append: bool = False,
) -> Generator[os._Environ, Any, Any]:
"""Create a context with specified environment variables set.
It is useful for setting the :code`VINEYARD_IPC_SOCKET` environment
Expand All @@ -59,9 +67,13 @@ def envvars(key: str, value: str = None, append: bool = False) -> None:
# env :code:`KEY1` will be set as None and :code:`KEY2` will
# be set as :code:`value2`.
"""
items = key
if isinstance(key, str):
items = {key: value}
if value is None:
items = dict()
else:
items: Dict[str, str] = {key: value}
else:
items: Dict[str, str] = key
original_items = dict()
for k, v in items.items():
original_items[k] = os.environ.get(k, None)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ all_files = 1
fresh-env = 1

[upload_docs]
upload-dir = docs/_build/html
upload_dir = docs/_build/html
2 changes: 1 addition & 1 deletion setup.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ all_files = 1
fresh-env = 1

[upload_docs]
upload-dir = docs/_build/html
upload_dir = docs/_build/html

0 comments on commit 6303ccb

Please sign in to comment.