Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#5232)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](astral-sh/ruff-pre-commit@v0.2.2...v0.3.2)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Ruff corrections

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ken Odegard <kodegard@anaconda.com>
  • Loading branch information
pre-commit-ci[bot] and kenodegard authored Mar 15, 2024
1 parent 67b90dd commit 3584ec9
Show file tree
Hide file tree
Showing 30 changed files with 61 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ repos:
# auto format Python codes within docstrings
- id: blacken-docs
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
rev: v0.3.2
hooks:
# lint & attempt to correct failures (e.g. pyupgrade)
- id: ruff
Expand Down
1 change: 1 addition & 0 deletions conda_build/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Conda-build abides by CEP-8 which specifies using CalVer, so the dev version is:
YY.MM.MICRO.devN+gHASH[.dirty]
"""

try:
from setuptools_scm import get_version

Expand Down
1 change: 1 addition & 0 deletions conda_build/_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This is code that is added to noarch Python packages. See
conda_build/noarch_python.py.
"""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions conda_build/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Design philosophy: put variability into config. Make each function here accept kwargs,
but only use those kwargs in config. Config must change to support new features elsewhere.
"""

from __future__ import annotations

# imports are done locally to keep the api clean and limited strictly
Expand Down
1 change: 1 addition & 0 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
Module that does most of the heavy lifting for the ``conda build`` command.
"""

import fnmatch
import json
import os
Expand Down
1 change: 1 addition & 0 deletions conda_build/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
Module to store conda build settings.
"""

from __future__ import annotations

import copy
Expand Down
1 change: 1 addition & 0 deletions conda_build/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
Tools for converting conda packages
"""

import glob
import hashlib
import json
Expand Down
1 change: 1 addition & 0 deletions conda_build/create_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
Module to handle generating test files.
"""

from __future__ import annotations

import json
Expand Down
1 change: 1 addition & 0 deletions conda_build/deprecations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (C) 2014 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
"""Tools to aid in deprecating code."""

from __future__ import annotations

import sys
Expand Down
36 changes: 5 additions & 31 deletions conda_build/jinja_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,39 +73,13 @@ def __init__(

# Using any of these methods on an Undefined variable
# results in another Undefined variable.
__add__ = (
__radd__
) = (
__mul__
) = (
__rmul__
) = (
__div__
) = (
__rdiv__
) = (
__truediv__
) = (
__add__ = __radd__ = __mul__ = __rmul__ = __div__ = __rdiv__ = __truediv__ = (
__rtruediv__
) = (
__floordiv__
) = (
__rfloordiv__
) = (
__mod__
) = (
__rmod__
) = (
__pos__
) = (
__neg__
) = (
) = __floordiv__ = __rfloordiv__ = __mod__ = __rmod__ = __pos__ = __neg__ = (
__call__
) = (
__getitem__
) = __lt__ = __le__ = __gt__ = __ge__ = __complex__ = __pow__ = __rpow__ = (
lambda self, *args, **kwargs: self._return_undefined(self._undefined_name)
)
) = __getitem__ = __lt__ = __le__ = __gt__ = __ge__ = __complex__ = __pow__ = (
__rpow__
) = lambda self, *args, **kwargs: self._return_undefined(self._undefined_name)

# Accessing an attribute of an Undefined variable
# results in another Undefined variable.
Expand Down
12 changes: 5 additions & 7 deletions conda_build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1341,8 +1341,7 @@ def fromdict(cls, metadata, config=None, variant=None):
return m

@overload
def get_section(self, section: Literal["source", "outputs"]) -> list[dict]:
...
def get_section(self, section: Literal["source", "outputs"]) -> list[dict]: ...

@overload
def get_section(
Expand All @@ -1356,8 +1355,7 @@ def get_section(
"about",
"extra",
],
) -> dict:
...
) -> dict: ...

def get_section(self, name):
section = self.meta.get(name)
Expand Down Expand Up @@ -2553,9 +2551,9 @@ def get_output_metadata_set(
)
] = (out, out_metadata)
out_metadata_map[HashableDict(out)] = out_metadata
ref_metadata.other_outputs = (
out_metadata.other_outputs
) = all_output_metadata
ref_metadata.other_outputs = out_metadata.other_outputs = (
all_output_metadata
)
except SystemExit:
if not permit_undefined_jinja:
raise
Expand Down
8 changes: 3 additions & 5 deletions conda_build/os_utils/macho.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,10 @@ def find_apple_cctools_executable(name, build_prefix, nofail=False):
tool = tool_xcr
if os.path.exists(tool):
return tool
except Exception as _: # noqa
except Exception: # noqa
print(
"ERROR :: Failed to run `{}`. Please use `conda` to install `cctools` into your base environment.\n"
" An option on macOS is to install `Xcode` or `Command Line Tools for Xcode`.".format(
tool
)
f"ERROR :: Failed to run `{tool}`. Use `conda` to install `cctools` into your base environment.\n"
f" An option on macOS is to install `Xcode` or `Command Line Tools for Xcode`."
)
sys.exit(1)
return tool
Expand Down
6 changes: 4 additions & 2 deletions conda_build/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -1402,9 +1402,11 @@ def check_overlinking_impl(
if diffs:
log = utils.get_logger(__name__)
log.warning(
"Partially parsed some '.tbd' files in sysroot {}, pretending .tbds are their install-names\n"
"Partially parsed some '.tbd' files in sysroot %s, pretending .tbds are their install-names\n"
"Adding support to 'conda-build' for parsing these in 'liefldd.py' would be easy and useful:\n"
"{} ...".format(sysroot, list(diffs)[1:3])
"%s...",
sysroot,
list(diffs)[1:3],
)
sysroots_files[srs] = sysroot_files
sysroots_files = OrderedDict(
Expand Down
3 changes: 1 addition & 2 deletions conda_build/skeletons/cpan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
Tools for converting CPAN packages to conda recipes.
"""

import codecs
import gzip
import hashlib
Expand Down Expand Up @@ -149,7 +150,6 @@


class InvalidReleaseError(RuntimeError):

"""
An exception that is raised when a release is not available on MetaCPAN.
"""
Expand All @@ -158,7 +158,6 @@ class InvalidReleaseError(RuntimeError):


class PerlTmpDownload(TmpDownload):

"""
Subclass Conda's TmpDownload to replace : in download filenames.
Critical on win.
Expand Down
1 change: 1 addition & 0 deletions conda_build/skeletons/cran.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
Tools for converting Cran packages to conda recipes.
"""

from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions conda_build/skeletons/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
Tools for converting PyPI packages to conda recipes.
"""

import keyword
import logging
import os
Expand Down
5 changes: 2 additions & 3 deletions conda_build/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,8 @@ def git_mirror_checkout_recursive(
)
if verbose:
print(
"Relative submodule {} found: url is {}, submod_mirror_dir is {}".format(
submod_name, submod_url, submod_mirror_dir
)
f"Relative submodule {submod_name} found: url is {submod_url}, "
f"submod_mirror_dir is {submod_mirror_dir}"
)
with TemporaryDirectory() as temp_checkout_dir:
git_mirror_checkout_recursive(
Expand Down
11 changes: 5 additions & 6 deletions conda_build/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,9 @@ def convert_path_for_cygwin_or_msys2(exe, path):


def get_skip_message(m):
return "Skipped: {} from {} defines build/skip for this configuration ({}).".format(
m.name(), m.path, {k: m.config.variant[k] for k in m.get_used_vars()}
return (
f"Skipped: {m.name()} from {m.path} defines build/skip for this configuration "
f"({({k: m.config.variant[k] for k in m.get_used_vars()})})."
)


Expand Down Expand Up @@ -1897,13 +1898,11 @@ def sort_list_in_nested_structure(dictionary, omissions=""):


@overload
def ensure_valid_spec(spec: str, warn: bool = False) -> str:
...
def ensure_valid_spec(spec: str, warn: bool = False) -> str: ...


@overload
def ensure_valid_spec(spec: MatchSpec, warn: bool = False) -> MatchSpec:
...
def ensure_valid_spec(spec: MatchSpec, warn: bool = False) -> MatchSpec: ...


def ensure_valid_spec(spec: str | MatchSpec, warn: bool = False) -> str | MatchSpec:
Expand Down
29 changes: 9 additions & 20 deletions conda_build/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause
"""This file handles the parsing of feature specifications from files,
ending up with a configuration matrix"""

import os.path
import re
import sys
Expand Down Expand Up @@ -303,15 +304,10 @@ def _combine_spec_dictionaries(
ensure_list(v)
):
raise ValueError(
"All entries associated by a zip_key "
"field must be the same length. In {}, {} and {} are "
"different ({} and {})".format(
spec_source,
k,
group_item,
len(ensure_list(v)),
len(ensure_list(spec[group_item])),
)
f"All entries associated by a zip_key "
f"field must be the same length. In {spec_source}, {k} and {group_item} "
f"are different ({len(ensure_list(v))} and "
f"{len(ensure_list(spec[group_item]))})"
)
values[group_item] = ensure_list(spec[group_item])
elif k in values:
Expand All @@ -338,17 +334,10 @@ def _combine_spec_dictionaries(
]
if len(missing_subvalues):
raise ValueError(
"variant config in {} is ambiguous because it\n"
"does not fully implement all zipped keys (To be clear: missing {})\n"
"or specifies a subspace that is not fully implemented (To be clear:\n"
".. we did not find {} from {} in {}:{}).".format(
spec_source,
missing_group_items,
missing_subvalues,
spec,
k,
values[k],
)
f"variant config in {spec_source} is ambiguous because it does not fully "
f"implement all zipped keys (missing {missing_group_items}) or specifies a "
f"subspace that is not fully implemented (we did not find {missing_subvalues} "
f"from {spec} in {k}:{values[k]})."
)

return values
Expand Down
1 change: 1 addition & 0 deletions tests/bdist-recipe/conda_build_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
"""
conda build test package
"""

print("conda_build_test has been imported")
17 changes: 8 additions & 9 deletions tests/test_api_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
This module tests the build API. These are high-level integration tests.
"""

from __future__ import annotations

import json
Expand Down Expand Up @@ -306,9 +307,7 @@ def test_output_build_path_git_source(testing_config):
test_path = os.path.join(
testing_config.croot,
testing_config.host_subdir,
"conda-build-test-source-git-jinja2-1.20.2-py{}{}{}_0_g262d444.tar.bz2".format(
sys.version_info.major, sys.version_info.minor, _hash
),
f"conda-build-test-source-git-jinja2-1.20.2-py{sys.version_info.major}{sys.version_info.minor}{_hash}_0_g262d444.tar.bz2",
)
assert output == test_path

Expand Down Expand Up @@ -819,15 +818,15 @@ def test_noarch(testing_workdir):
def test_disable_pip(testing_metadata):
testing_metadata.config.disable_pip = True
testing_metadata.meta["requirements"] = {"host": ["python"], "run": ["python"]}
testing_metadata.meta["build"][
"script"
] = 'python -c "import pip; print(pip.__version__)"'
testing_metadata.meta["build"]["script"] = (
'python -c "import pip; print(pip.__version__)"'
)
with pytest.raises(subprocess.CalledProcessError):
api.build(testing_metadata)

testing_metadata.meta["build"][
"script"
] = 'python -c "import setuptools; print(setuptools.__version__)"'
testing_metadata.meta["build"]["script"] = (
'python -c "import setuptools; print(setuptools.__version__)"'
)
with pytest.raises(subprocess.CalledProcessError):
api.build(testing_metadata)

Expand Down
1 change: 1 addition & 0 deletions tests/test_api_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This module tests the test API. These are high-level integration tests. Lower level unit tests
should go in test_render.py
"""

from __future__ import annotations

import subprocess
Expand Down
1 change: 1 addition & 0 deletions tests/test_api_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This module tests the test API. These are high-level integration tests. Lower level unit tests
should go in test_render.py
"""

import os
import re

Expand Down
1 change: 0 additions & 1 deletion tests/test_api_skeleton_cpan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
conda_build.api.skeletonize and check the output files
"""


import pytest

from conda_build import api
Expand Down
1 change: 1 addition & 0 deletions tests/test_api_skeleton_cran.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Integrative tests of the CRAN skeleton that start from
conda_build.api.skeletonize and check the output files
"""

from pathlib import Path
from typing import Sequence

Expand Down
1 change: 1 addition & 0 deletions tests/test_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
This module tests the test API. These are high-level integration tests.
"""

import os

import pytest
Expand Down
Loading

0 comments on commit 3584ec9

Please sign in to comment.