Skip to content

Commit

Permalink
chore: Reformat files with black
Browse files Browse the repository at this point in the history
  • Loading branch information
ninetteadhikari committed Jun 27, 2024
1 parent 352007f commit 4b4ddc3
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 77 deletions.
6 changes: 1 addition & 5 deletions conda_smithy/anaconda_token_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
import sys
from contextlib import redirect_stderr, redirect_stdout
from github import Github
from typing import (
List,
Optional,
Union
)
from typing import List, Optional, Union

import requests

Expand Down
33 changes: 11 additions & 22 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
try:
import simplejson as json
except ImportError:
import json # type: ignore
import json # type: ignore

from conda.models.match_spec import MatchSpec
from conda.models.version import VersionOrder
Expand Down Expand Up @@ -107,10 +107,7 @@ def warn_once(msg: str):


def package_key(
config: Dict[
str,
Union[List[str], List[List[str]], OrderedDict]
],
config: Dict[str, Union[List[str], List[List[str]], OrderedDict]],
used_loop_vars: Set[str],
subdir: str,
) -> str:
Expand Down Expand Up @@ -178,9 +175,7 @@ def merge_list_of_dicts(
return squished_dict


def argsort(
seq: List[tuple]
) -> List[int]:
def argsort(seq: List[tuple]) -> List[int]:
return sorted(range(len(seq)), key=seq.__getitem__)


Expand Down Expand Up @@ -346,9 +341,7 @@ def _trim_unused_zip_keys(all_used_vars):
del all_used_vars["zip_keys"]


def _trim_unused_pin_run_as_build(
all_used_vars: dict
):
def _trim_unused_pin_run_as_build(all_used_vars: dict):
"""Remove unused keys in pin_run_as_build sets"""
pkgs = all_used_vars.get("pin_run_as_build", {})
used_pkgs = {}
Expand All @@ -370,10 +363,7 @@ def _get_used_key_values_by_input_order(
Union[set, dict, list, tuple],
],
],
squished_used_variants: Union[
OrderedDict,
dict
],
squished_used_variants: Union[OrderedDict, dict],
all_used_vars: Set[str],
) -> tuple:
used_key_values = {
Expand Down Expand Up @@ -737,9 +727,7 @@ def _collapse_subpackage_variants(
)


def _yaml_represent_ordereddict(
yaml_representer, data: OrderedDict
):
def _yaml_represent_ordereddict(yaml_representer, data: OrderedDict):
# represent_dict processes dict-likes with a .sort() method or plain iterables of key-value
# pairs. Only for the latter it never sorts and retains the order of the OrderedDict.
return yaml.representer.SafeRepresenter.represent_dict(
Expand Down Expand Up @@ -969,9 +957,10 @@ def migrate_combined_spec(

def _conda_build_api_render_for_smithy(
recipe_path: str,
config = None,
variants: Optional[Dict[str, Union[List[str], List[List[str]], Dict[str, Dict[str, str]]]]]
= None,
config=None,
variants: Optional[
Dict[str, Union[List[str], List[List[str]], Dict[str, Dict[str, str]]]]
] = None,
permit_unsatisfiable_variants: bool = True,
finalize: bool = True,
bypass_env_check: bool = False,
Expand Down Expand Up @@ -2261,7 +2250,7 @@ def render_README(
err
)
)
except json.decoder.JSONDecodeError: # type: ignore
except json.decoder.JSONDecodeError: # type: ignore
azure_build_id_from_token(forge_config)

logger.debug("README")
Expand Down
11 changes: 2 additions & 9 deletions conda_smithy/feedstock_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@
import shutil
import stat
from io import TextIOWrapper
from typing import (
Iterator,
Optional,
Any,
Union
)
from typing import Iterator, Optional, Any, Union


def get_repo(
path: str, search_parent_directories: bool = True
):
def get_repo(path: str, search_parent_directories: bool = True):
repo = None
try:
import git
Expand Down
8 changes: 5 additions & 3 deletions conda_smithy/lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ def lint_section_order(
lambda s: "'%s'" % s, section_order_sorted
)
section_order_sorted_str_joined = ", ".join(section_order_sorted_str)
section_order_sorted_str_with_brackets = "[" + section_order_sorted_str_joined + "]"
section_order_sorted_str_with_brackets = (
"[" + section_order_sorted_str_joined + "]"
)
lints.append(
"The top level meta keys are in an unexpected order. "
"Expecting {}.".format(section_order_sorted_str_with_brackets)
Expand Down Expand Up @@ -839,7 +841,7 @@ def check_pins_build_and_requirements(top_level):
cmd + shell_scripts,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
env={ # type: ignore
env={ # type: ignore
"PATH": os.getenv("PATH")
}, # exclude other env variables to protect against token leakage
)
Expand Down Expand Up @@ -1354,7 +1356,7 @@ def jinja_lines(lines: TextIOWrapper) -> Iterator[Tuple[str, int]]:
yield line, i


def _format_validation_msg(error: "jsonschema.ValidationError") -> str: # type: ignore
def _format_validation_msg(error: "jsonschema.ValidationError") -> str: # type: ignore
"""Use the data on the validation error to generate improved reporting.
If available, get the help URL from the first level of the JSON path:
Expand Down
47 changes: 24 additions & 23 deletions conda_smithy/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from conda.base.constants import KNOWN_SUBDIRS

try:
from enum import StrEnum # type: ignore
from enum import StrEnum # type: ignore
except ImportError:
from backports.strenum import StrEnum

Expand Down Expand Up @@ -371,7 +371,7 @@ class BotConfig(BaseModel):
)

version_updates: Optional[BotConfigVersionUpdates] = Field(
default_factory=BotConfigVersionUpdates, # type: ignore
default_factory=BotConfigVersionUpdates, # type: ignore
description="Bot config for version update PRs",
)

Expand Down Expand Up @@ -467,20 +467,21 @@ class DefaultTestPlatforms(StrEnum):
native = "native"
native_and_emulated = "native_and_emulated"


buildPlatform_fields: Dict[str, Any] = {
platform.value: (Optional[Platforms], Field(default=platform.value))
for platform in Platforms
}
platform.value: (Optional[Platforms], Field(default=platform.value))
for platform in Platforms
}
BuildPlatform = create_model(
"build_platform",
**buildPlatform_fields,
)

OSVersion_fields: Dict[str, Any] = {
platform.value: (Optional[Union[str, Nullable]], Field(default=None))
for platform in Platforms
if platform.value.startswith("linux")
}
platform.value: (Optional[Union[str, Nullable]], Field(default=None))
for platform in Platforms
if platform.value.startswith("linux")
}
OSVersion = create_model(
"os_version",
**OSVersion_fields,
Expand All @@ -489,15 +490,15 @@ class DefaultTestPlatforms(StrEnum):
ProviderType = Union[List[CIservices], CIservices, bool, Nullable]

provider_fields: Dict[str, Any] = dict(
[
(str(plat), (Optional[ProviderType], Field(default=None)))
for plat in list(PlatformsAliases) + list(Platforms)
]
+ [
(str(plat), (Optional[ProviderType], Field(default="azure")))
for plat in ("linux_64", "osx_64", "win_64")
]
)
[
(str(plat), (Optional[ProviderType], Field(default=None)))
for plat in list(PlatformsAliases) + list(Platforms)
]
+ [
(str(plat), (Optional[ProviderType], Field(default="azure")))
for plat in ("linux_64", "osx_64", "win_64")
]
)
Provider = create_model(
"provider",
**provider_fields,
Expand Down Expand Up @@ -596,7 +597,7 @@ class ConfigModel(BaseModel):
)

bot: Optional[BotConfig] = Field(
default_factory=BotConfig, # type: ignore
default_factory=BotConfig, # type: ignore
description=cleandoc(
"""
This dictates the behavior of the conda-forge auto-tick bot which issues
Expand Down Expand Up @@ -644,7 +645,7 @@ class ConfigModel(BaseModel):
),
)

build_platform: Optional[BuildPlatform] = Field( # type: ignore
build_platform: Optional[BuildPlatform] = Field( # type: ignore
default_factory=BuildPlatform,
description=cleandoc(
"""
Expand Down Expand Up @@ -738,7 +739,7 @@ class ConfigModel(BaseModel):
),
)

noarch_platforms: Optional[Union[Platforms, List[Platforms]]] = Field( # type: ignore
noarch_platforms: Optional[Union[Platforms, List[Platforms]]] = Field( # type: ignore
default_factory=lambda: ["linux_64"],
description=cleandoc(
"""
Expand All @@ -761,7 +762,7 @@ class ConfigModel(BaseModel):
),
)

os_version: Optional[OSVersion] = Field( # type: ignore
os_version: Optional[OSVersion] = Field( # type: ignore
default_factory=OSVersion,
description=cleandoc(
"""
Expand All @@ -779,7 +780,7 @@ class ConfigModel(BaseModel):
),
)

provider: Optional[Provider] = Field( # type: ignore
provider: Optional[Provider] = Field( # type: ignore
default_factory=Provider,
description=cleandoc(
"""
Expand Down
6 changes: 1 addition & 5 deletions conda_smithy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
from collections import defaultdict
from contextlib import contextmanager
from conda_build.metadata import MetaData
from typing import (
Dict,
Union,
Any
)
from typing import Dict, Union, Any

import ruamel.yaml
from ruamel.yaml.comments import CommentedMap
Expand Down
15 changes: 9 additions & 6 deletions conda_smithy/validate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@ def get_validator_class():
def validate_json_schema(
config: Union[
CommentedMap,
Dict[str, Union[
bool,
Dict[
str,
List[str],
Dict[str, bool],
Dict[str, Dict[str, str]]
]]
Union[
bool,
str,
List[str],
Dict[str, bool],
Dict[str, Dict[str, str]],
],
],
],
schema_file: Optional[Path],
) -> tuple:
Expand Down
2 changes: 1 addition & 1 deletion conda_smithy/variant_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def variant_key_add(
v_left: Union[List[str], List[float]],
v_right: Union[List[str], List[float]],
ordering: Optional[List[str]] = None,
) -> List[Union[str,float]]:
) -> List[Union[str, float]]:
"""Version summation adder.
This takes the higher version of the two things.
Expand Down
4 changes: 1 addition & 3 deletions tests/test_feedstock_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ def keep_dir(dirname: str):
fh.write("")


def parameterize() -> (
Iterator[tuple]
):
def parameterize() -> Iterator[tuple]:
for pathfunc in [
lambda pth, tmp_dir: os.path.relpath(pth, tmp_dir),
lambda pth, tmp_dir: pth,
Expand Down

0 comments on commit 4b4ddc3

Please sign in to comment.