Skip to content

Commit

Permalink
fix: Update types to address errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ninetteadhikari committed Aug 28, 2024
1 parent b30e387 commit 2d221ce
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 19 deletions.
4 changes: 3 additions & 1 deletion conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2467,7 +2467,9 @@ def _legacy_compatibility_checks(


def _load_forge_config(
forge_dir: str, exclusive_config_file: str, forge_yml: Optional[str] = None
forge_dir: str,
exclusive_config_file: Optional[str],
forge_yml: Optional[str] = None,
) -> Dict[str, Any]:
config = _read_forge_config(forge_dir, forge_yml=forge_yml)

Expand Down
8 changes: 4 additions & 4 deletions conda_smithy/lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
NEEDED_FAMILIES = ["gpl", "bsd", "mit", "apache", "psf"]


def lintify_forge_yaml(recipe_dir: Optional[str] = None) -> (list, list):
def lintify_forge_yaml(recipe_dir: Optional[str] = None) -> tuple:
if recipe_dir:
forge_yaml_filename = (
glob(os.path.join(recipe_dir, "..", "conda-forge.yml"))
Expand Down Expand Up @@ -112,8 +112,8 @@ def lintify_meta_yaml(
conda_forge: bool = False,
recipe_version: int = 0,
) -> Tuple[List[str], List[str]]:
lints = []
hints = []
lints: list = []
hints: list = []
major_sections = list(meta.keys())

# If the recipe_dir exists (no guarantee within this function) , we can
Expand Down Expand Up @@ -611,7 +611,7 @@ def run_conda_forge_specific(
)


def _format_validation_msg(error: jsonschema.ValidationError):
def _format_validation_msg(error):
"""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
4 changes: 2 additions & 2 deletions conda_smithy/linter/conda_recipe_v1_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def lint_recipe_tests(
lints: List[str],
hints: List[str],
):
tests_lints = []
tests_hints = []
tests_lints: list = []
tests_hints: list = []

if not test_section:
if not outputs_section:
Expand Down
4 changes: 2 additions & 2 deletions conda_smithy/linter/lints.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def lint_section_order(
section_order_sorted = sorted(major_sections, key=order.index)

if major_sections != section_order_sorted:
section_order_sorted_str = map(
section_order_sorted_str: str | map[str] = map(
lambda s: f"'{s}'", section_order_sorted
)
section_order_sorted_str = ", ".join(section_order_sorted_str)
Expand Down Expand Up @@ -83,7 +83,7 @@ def lint_recipe_maintainers(extra_section, lints):


def lint_recipe_have_tests(
recipe_dir: str,
recipe_dir: Optional[str],
test_section: List[Dict[str, Any]],
outputs_section: List[Dict[str, Any]],
lints: List[str],
Expand Down
1 change: 1 addition & 0 deletions conda_smithy/linter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def _lint_package_version(version: Optional[str]) -> Optional[str]:
VersionOrder(ver)
except InvalidVersionSpec as e:
return invalid_version.format(ver=ver, err=e)
return None


@lru_cache(maxsize=1)
Expand Down
6 changes: 3 additions & 3 deletions conda_smithy/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from pydantic import BaseModel, ConfigDict, Field, create_model

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


from conda_smithy.validate_schema import (
Expand Down Expand Up @@ -493,7 +493,7 @@ def get_subdirs() -> List[str]:
]


Platforms = StrEnum("Platforms", get_subdirs())
Platforms = StrEnum("Platforms", get_subdirs()) # type: ignore


class ChannelPriorityConfig(StrEnum):
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ module = [
'license_expression',
'cirun',
'scrypt',
'toolz'
'toolz',
'rattler_build_conda_compat.*',
'tlz'
]
ignore_missing_imports = true
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


class ConfigYAML(typing.NamedTuple):
workdir: Path
workdir: str
recipe_name: str
type: str

Expand Down Expand Up @@ -61,7 +61,7 @@ def recipe_dirname():


@pytest.fixture(scope="function", params=["conda-build", "rattler-build"])
def config_yaml(testing_workdir: str, recipe_dirname: str, request) -> str:
def config_yaml(testing_workdir: str, recipe_dirname: str, request):
config: dict = {"python": ["2.7", "3.5"], "r_base": ["3.3.2", "3.4.2"]}
os.makedirs(os.path.join(testing_workdir, recipe_dirname))
with open(os.path.join(testing_workdir, "config.yaml"), "w") as f:
Expand Down Expand Up @@ -650,7 +650,7 @@ def jinja_env():


@pytest.fixture(scope="function")
def v1_noarch_recipe_with_context(testing_workdir: Path, recipe_dirname):
def v1_noarch_recipe_with_context(testing_workdir: str, recipe_dirname):
with open(os.path.join(testing_workdir, "conda-forge.yml"), "w") as f:
config = {
"recipe_dir": recipe_dirname,
Expand Down Expand Up @@ -688,7 +688,7 @@ def v1_noarch_recipe_with_context(testing_workdir: Path, recipe_dirname):


@pytest.fixture(scope="function")
def v1_recipe_with_multiple_outputs(testing_workdir: Path, recipe_dirname):
def v1_recipe_with_multiple_outputs(testing_workdir: str, recipe_dirname):
with open(os.path.join(testing_workdir, "conda-forge.yml"), "w") as f:
config = {
"recipe_dir": recipe_dirname,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def is_gh_token_set() -> bool:


@contextmanager
def get_recipe_in_dir(recipe_name: str) -> Path:
def get_recipe_in_dir(recipe_name: str):
base_dir = Path(__file__).parent
recipe_path = base_dir / "recipes" / recipe_name
assert recipe_path.exists(), f"Recipe {recipe_name} does not exist"
Expand Down Expand Up @@ -2677,7 +2677,7 @@ def test_lint_wheels(tmp_path, yaml_block, annotation):

@pytest.mark.parametrize("recipe_version", [0, 1])
def test_pin_compatible_in_run_exports(recipe_version: int):
meta = {
meta: dict = {
"package": {
"name": "apackage",
}
Expand Down

0 comments on commit 2d221ce

Please sign in to comment.