Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix python requirement #2242

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
26 changes: 20 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ on:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: false

defaults:
run:
shell: bash -el {0}

jobs:
tests:
name: tests
runs-on: "ubuntu-latest"
runs-on: "macos-latest"
strategy:
matrix:
python_version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -28,16 +32,22 @@ jobs:
micromamba-version: 1.5.12-0
cache-environment: true
create-args: >-
python=3.11
python=${{ matrix.python_version }}
coverage
coveralls
conda-recipe-manager>=0.4.1
conda-souschef
conda-forge-tick

- name: install conda-forge-tick and conda-recipe-manager
run: |
if [[ "${{ matrix.python_version }}" != "3.10" ]]; then
conda install "conda-recipe-manager>=0.4.1" conda-forge-tick --yes --quiet
fi

- name: install conda-smithy
run: |
conda uninstall --force --yes conda-smithy
if [[ "${{ matrix.python_version }}" != "3.10" ]]; then
conda uninstall --force --yes conda-smithy
fi
python -m pip install -v --no-build-isolation -e .
git config --global user.email "[email protected]"
git config --global user.name "smithy"
Expand Down Expand Up @@ -65,6 +75,10 @@ jobs:

python -m pip install -v --no-build-isolation -e .

- name: run tests without token
run: |
pytest tests

- name: run tests
run: |
pytest tests --cov conda_smithy --cov-report lcov --cov-report term-missing
Expand Down
8 changes: 4 additions & 4 deletions conda_smithy/cirun_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from functools import lru_cache
from typing import Any, Optional
from typing import Any

from cirun import Cirun

Expand Down Expand Up @@ -44,12 +44,12 @@ def add_repo_to_cirun_resource(
resources: list[str],
teams: list,
roles: list,
users_from_json: Optional[str] = None,
cirun_policy_args: Optional[list[str]] = None,
users_from_json: str | None = None,
cirun_policy_args: list[str] | None = None,
) -> dict[str, Any]:
"""Grant access to a cirun resource to a particular repository, with a particular policy."""
cirun = _get_cirun_client()
policy_args: Optional[dict[str, Any]] = None
policy_args: dict[str, Any] | None = None
if cirun_policy_args and "pull_request" in cirun_policy_args:
policy_args = {"pull_request": True}
print(
Expand Down
7 changes: 3 additions & 4 deletions conda_smithy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import tempfile
import time
from textwrap import dedent
from typing import Optional, Union

import conda # noqa
from conda_build.metadata import MetaData
Expand Down Expand Up @@ -35,7 +34,7 @@ def default_feedstock_config_path(feedstock_directory):


def generate_feedstock_content(
target_directory, source_recipe_dir, conda_build_tool: Optional[str] = None
target_directory, source_recipe_dir, conda_build_tool: str | None = None
):
target_directory = os.path.abspath(target_directory)
recipe_dir = "recipe"
Expand Down Expand Up @@ -130,7 +129,7 @@ def __call__(self, args):

# Get some information about the source recipe.
# detect if it's old recipe or new one
meta: Union[MetaData, RattlerMetaData]
meta: MetaData | RattlerMetaData

build_tool = CONDA_BUILD

Expand All @@ -143,7 +142,7 @@ def __call__(self, args):
else:
meta = RattlerMetaData(args.recipe_directory)

conda_build_tool: Optional[str] = (
conda_build_tool: str | None = (
RATTLER_BUILD if isinstance(meta, RattlerMetaData) else None
)

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 @@ -8,7 +8,7 @@
from inspect import cleandoc
from pathlib import Path
from textwrap import indent
from typing import Any, Optional
from typing import Any

import github
import github.Auth
Expand Down Expand Up @@ -84,7 +84,7 @@
NEEDED_FAMILIES = ["gpl", "bsd", "mit", "apache", "psf"]


def _get_forge_yaml(recipe_dir: Optional[str] = None) -> dict:
def _get_forge_yaml(recipe_dir: str | None = None) -> dict:
if recipe_dir:
forge_yaml_filename = (
glob(os.path.join(recipe_dir, "..", "conda-forge.yml"))
Expand All @@ -106,15 +106,15 @@ def _get_forge_yaml(recipe_dir: Optional[str] = None) -> dict:
return forge_yaml


def lintify_forge_yaml(recipe_dir: Optional[str] = None) -> (list, list):
def lintify_forge_yaml(recipe_dir: str | None = None) -> (list, list):
forge_yaml = _get_forge_yaml(recipe_dir)
# This is where we validate against the jsonschema and execute our custom validators.
return validate_json_schema(forge_yaml)


def lintify_meta_yaml(
meta: Any,
recipe_dir: Optional[str] = None,
recipe_dir: str | None = None,
conda_forge: bool = False,
recipe_version: int = 0,
) -> tuple[list[str], list[str]]:
Expand Down
6 changes: 3 additions & 3 deletions conda_smithy/linter/conda_recipe_v1_linter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from typing import Any, Optional
from typing import Any

from rattler_build_conda_compat.jinja.jinja import (
RecipeWithContext,
Expand Down Expand Up @@ -40,7 +40,7 @@


def lint_recipe_tests(
recipe_dir: Optional[str],
recipe_dir: str | None,
test_section: list[dict[str, Any]],
outputs_section: list[dict[str, Any]],
lints: list[str],
Expand Down Expand Up @@ -117,7 +117,7 @@ def get_recipe_name(recipe_content: RecipeWithContext) -> str:
return package_name or recipe_name


def get_recipe_version(recipe_content: RecipeWithContext) -> Optional[str]:
def get_recipe_version(recipe_content: RecipeWithContext) -> str | None:
rendered_context_recipe = render_recipe_with_context(recipe_content)
package_version = rendered_context_recipe.get("package", {}).get("version")
recipe_version = rendered_context_recipe.get("recipe", {}).get("version")
Expand Down
10 changes: 5 additions & 5 deletions conda_smithy/linter/lints.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re
import tempfile
from collections.abc import Sequence
from typing import Any, Literal, Optional
from typing import Any, Literal

from conda.models.version import VersionOrder
from rattler_build_conda_compat.jinja.jinja import render_recipe_with_context
Expand Down Expand Up @@ -329,7 +329,7 @@ def lint_subheaders(major_sections, meta, lints):
)


def lint_noarch(noarch_value: Optional[str], lints):
def lint_noarch(noarch_value: str | None, lints):
if noarch_value is not None:
valid_noarch_values = ["python", "generic"]
if noarch_value not in valid_noarch_values:
Expand All @@ -340,7 +340,7 @@ def lint_noarch(noarch_value: Optional[str], lints):


def lint_recipe_v1_noarch_and_runtime_dependencies(
noarch_value: Optional[Literal["python", "generic"]],
noarch_value: Literal["python", "generic"] | None,
raw_requirements_section: dict[str, Any],
build_section: dict[str, Any],
noarch_platforms: bool,
Expand Down Expand Up @@ -712,7 +712,7 @@ def lint_check_usage_of_whls(meta_fname, noarch_value, lints, hints):


def lint_rust_licenses_are_bundled(
build_reqs: Optional[list[str]],
build_reqs: list[str] | None,
lints: list[str],
recipe_version: int = 0,
):
Expand All @@ -732,7 +732,7 @@ def lint_rust_licenses_are_bundled(


def lint_go_licenses_are_bundled(
build_reqs: Optional[list[str]],
build_reqs: list[str] | None,
lints: list[str],
recipe_version: int = 0,
):
Expand Down
9 changes: 4 additions & 5 deletions conda_smithy/linter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from collections.abc import Mapping, Sequence
from functools import lru_cache
from glob import glob
from typing import Optional, Union

import requests
from conda.models.version import InvalidVersionSpec, VersionOrder
Expand Down Expand Up @@ -99,7 +98,7 @@ def get_meta_section(parent, name, lints):
return section


def get_recipe_v1_section(meta, name) -> Union[dict, list[dict]]:
def get_recipe_v1_section(meta, name) -> dict | list[dict]:
if name == "requirements":
return rattler_loader.load_all_requirements(meta)
elif name == "tests":
Expand Down Expand Up @@ -128,7 +127,7 @@ def get_list_section(parent, name, lints, allow_single=False):
return [{}]


def find_local_config_file(recipe_dir: str, filename: str) -> Optional[str]:
def find_local_config_file(recipe_dir: str, filename: str) -> str | None:
# support
# 1. feedstocks
# 2. staged-recipes with custom conda-forge.yaml in recipe
Expand Down Expand Up @@ -195,7 +194,7 @@ def jinja_lines(lines):
yield line, i


def _lint_recipe_name(recipe_name: str) -> Optional[str]:
def _lint_recipe_name(recipe_name: str) -> str | None:
wrong_recipe_name = "Recipe name has invalid characters. only lowercase alpha, numeric, underscores, hyphens and dots allowed"

if re.match(r"^[a-z0-9_\-.]+$", recipe_name) is None:
Expand All @@ -204,7 +203,7 @@ def _lint_recipe_name(recipe_name: str) -> Optional[str]:
return None


def _lint_package_version(version: Optional[str]) -> Optional[str]:
def _lint_package_version(version: str | None) -> str | None:
no_package_version = "Package version is missing."
invalid_version = "Package version {ver} doesn't match conda spec: {err}"

Expand Down
Loading
Loading