From 608ed967e1289befcd63a8f2ce70c18d9b492517 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Mon, 3 Feb 2025 00:49:38 -0800 Subject: [PATCH] style: fix `not in` and `is not` (#48831) These are some changes that `ruff check --fix` would make that the current `spack style` also agrees with. Make the changes now so that the `ruff` change is less disruptive. Signed-off-by: Todd Gamblin --- lib/spack/spack/container/__init__.py | 2 +- lib/spack/spack/installer.py | 2 +- lib/spack/spack/mirrors/mirror.py | 2 +- lib/spack/spack/test/concretization/requirements.py | 2 +- var/spack/repos/builtin/packages/ace/package.py | 2 +- var/spack/repos/builtin/packages/amrex/package.py | 2 +- var/spack/repos/builtin/packages/charmpp/package.py | 2 +- var/spack/repos/builtin/packages/dav-sdk/package.py | 2 +- var/spack/repos/builtin/packages/ecp-data-vis-sdk/package.py | 2 +- var/spack/repos/builtin/packages/ginkgo/package.py | 2 +- var/spack/repos/builtin/packages/hypre/package.py | 2 +- var/spack/repos/builtin/packages/petsc/package.py | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/spack/spack/container/__init__.py b/lib/spack/spack/container/__init__.py index 2b2d89d5813..b134aea05d0 100644 --- a/lib/spack/spack/container/__init__.py +++ b/lib/spack/spack/container/__init__.py @@ -57,7 +57,7 @@ def validate(configuration_file): # Set the default value of the concretization strategy to unify and # warn if the user explicitly set another value env_dict.setdefault("concretizer", {"unify": True}) - if not env_dict["concretizer"]["unify"] is True: + if env_dict["concretizer"]["unify"] is not True: warnings.warn( '"concretizer:unify" is not set to "true", which means the ' "generated image may contain different variants of the same " diff --git a/lib/spack/spack/installer.py b/lib/spack/spack/installer.py index 5e136eb23dc..067fe982c20 100644 --- a/lib/spack/spack/installer.py +++ b/lib/spack/spack/installer.py @@ -814,7 +814,7 @@ def get_depflags(self, pkg: "spack.package_base.PackageBase") -> int: # Include build dependencies if pkg is going to be built from sources, or # if build deps are explicitly requested. if include_build_deps or not ( - cache_only or pkg.spec.installed and not pkg.spec.dag_hash() in self.overwrite + cache_only or pkg.spec.installed and pkg.spec.dag_hash() not in self.overwrite ): depflag |= dt.BUILD if self.run_tests(pkg): diff --git a/lib/spack/spack/mirrors/mirror.py b/lib/spack/spack/mirrors/mirror.py index 1629cc9f759..7f3527a28c2 100644 --- a/lib/spack/spack/mirrors/mirror.py +++ b/lib/spack/spack/mirrors/mirror.py @@ -64,7 +64,7 @@ def from_local_path(path: str): @staticmethod def from_url(url: str): """Create an anonymous mirror by URL. This method validates the URL.""" - if not urllib.parse.urlparse(url).scheme in supported_url_schemes: + if urllib.parse.urlparse(url).scheme not in supported_url_schemes: raise ValueError( f'"{url}" is not a valid mirror URL. ' f"Scheme must be one of {supported_url_schemes}." diff --git a/lib/spack/spack/test/concretization/requirements.py b/lib/spack/spack/test/concretization/requirements.py index a7a3be14d13..72552398a45 100644 --- a/lib/spack/spack/test/concretization/requirements.py +++ b/lib/spack/spack/test/concretization/requirements.py @@ -182,7 +182,7 @@ def test_requirement_adds_version_satisfies( # Sanity check: early version of T does not include U s0 = spack.concretize.concretize_one("t@2.0") - assert not ("u" in s0) + assert "u" not in s0 conf_str = """\ packages: diff --git a/var/spack/repos/builtin/packages/ace/package.py b/var/spack/repos/builtin/packages/ace/package.py index 343556a35ca..d465d04eee2 100644 --- a/var/spack/repos/builtin/packages/ace/package.py +++ b/var/spack/repos/builtin/packages/ace/package.py @@ -32,7 +32,7 @@ def edit(self, spec, prefix): # Dictionary mapping: compiler-name : ACE config-label supported = {"intel": "_icc", "gcc": ""} - if not (self.compiler.name in supported): + if self.compiler.name not in supported: raise Exception( "compiler " + self.compiler.name + " not supported in ace spack-package" ) diff --git a/var/spack/repos/builtin/packages/amrex/package.py b/var/spack/repos/builtin/packages/amrex/package.py index 4e2f61f8e19..2790e23936c 100644 --- a/var/spack/repos/builtin/packages/amrex/package.py +++ b/var/spack/repos/builtin/packages/amrex/package.py @@ -360,7 +360,7 @@ def cmake_args(self): args.append("-DAMReX_GPU_BACKEND=SYCL") # SYCL GPU backend only supported with Intel's oneAPI or DPC++ compilers sycl_compatible_compilers = ["icpx"] - if not (os.path.basename(self.compiler.cxx) in sycl_compatible_compilers): + if os.path.basename(self.compiler.cxx) not in sycl_compatible_compilers: raise InstallError( "AMReX's SYCL GPU Backend requires the oneAPI CXX (icpx) compiler." ) diff --git a/var/spack/repos/builtin/packages/charmpp/package.py b/var/spack/repos/builtin/packages/charmpp/package.py index 56d7503d906..5ab829ada8d 100644 --- a/var/spack/repos/builtin/packages/charmpp/package.py +++ b/var/spack/repos/builtin/packages/charmpp/package.py @@ -276,7 +276,7 @@ def charmarch(self): # build-target=LIBS backend={0}'.format(b)) def install(self, spec, prefix): - if not ("backend=mpi" in self.spec) or not ("backend=netlrts" in self.spec): + if "backend=mpi" not in self.spec or "backend=netlrts" not in self.spec: if self.spec.satisfies("+pthreads"): raise InstallError( "The pthreads option is only available on the Netlrts and MPI network layers." diff --git a/var/spack/repos/builtin/packages/dav-sdk/package.py b/var/spack/repos/builtin/packages/dav-sdk/package.py index 936fe791ca6..5d660fd772d 100644 --- a/var/spack/repos/builtin/packages/dav-sdk/package.py +++ b/var/spack/repos/builtin/packages/dav-sdk/package.py @@ -30,7 +30,7 @@ def dav_sdk_depends_on(spec, when=None, propagate=None): # Map the propagated variants to the dependency variant. Some packages may need # overrides to propagate a dependency as something else, e.g., {"visit": "libsim"}. # Most call-sites will just use a list. - if not type(propagate) is dict: + if type(propagate) is not dict: propagate = dict([(v, v) for v in propagate]) # Determine the base variant diff --git a/var/spack/repos/builtin/packages/ecp-data-vis-sdk/package.py b/var/spack/repos/builtin/packages/ecp-data-vis-sdk/package.py index c2771e281bd..5976957e03e 100644 --- a/var/spack/repos/builtin/packages/ecp-data-vis-sdk/package.py +++ b/var/spack/repos/builtin/packages/ecp-data-vis-sdk/package.py @@ -30,7 +30,7 @@ def dav_sdk_depends_on(spec, when=None, propagate=None): # Map the propagated variants to the dependency variant. Some packages may need # overrides to propagate a dependency as something else, e.g., {"visit": "libsim"}. # Most call-sites will just use a list. - if not type(propagate) is dict: + if type(propagate) is not dict: propagate = dict([(v, v) for v in propagate]) # Determine the base variant diff --git a/var/spack/repos/builtin/packages/ginkgo/package.py b/var/spack/repos/builtin/packages/ginkgo/package.py index 7e5f2881e15..50d8d4dff9f 100644 --- a/var/spack/repos/builtin/packages/ginkgo/package.py +++ b/var/spack/repos/builtin/packages/ginkgo/package.py @@ -226,7 +226,7 @@ def cmake_args(self): if self.spec.satisfies("+sycl"): sycl_compatible_compilers = ["icpx"] - if not (os.path.basename(self.compiler.cxx) in sycl_compatible_compilers): + if os.path.basename(self.compiler.cxx) not in sycl_compatible_compilers: raise InstallError("ginkgo +sycl requires icpx compiler.") return args diff --git a/var/spack/repos/builtin/packages/hypre/package.py b/var/spack/repos/builtin/packages/hypre/package.py index c98252450d5..a7d8a8d35c6 100644 --- a/var/spack/repos/builtin/packages/hypre/package.py +++ b/var/spack/repos/builtin/packages/hypre/package.py @@ -322,7 +322,7 @@ def configure_args(self): if spec.satisfies("+sycl"): configure_args.append("--with-sycl") sycl_compatible_compilers = ["icpx"] - if not (os.path.basename(self.compiler.cxx) in sycl_compatible_compilers): + if os.path.basename(self.compiler.cxx) not in sycl_compatible_compilers: raise InstallError( "Hypre's SYCL GPU Backend requires the oneAPI CXX (icpx) compiler." ) diff --git a/var/spack/repos/builtin/packages/petsc/package.py b/var/spack/repos/builtin/packages/petsc/package.py index 93d245fc4b7..a1535f92d43 100644 --- a/var/spack/repos/builtin/packages/petsc/package.py +++ b/var/spack/repos/builtin/packages/petsc/package.py @@ -582,7 +582,7 @@ def configure_options(self): if "+sycl" in spec: sycl_compatible_compilers = ["icpx"] - if not (os.path.basename(self.compiler.cxx) in sycl_compatible_compilers): + if os.path.basename(self.compiler.cxx) not in sycl_compatible_compilers: raise InstallError("PETSc's SYCL GPU Backend requires oneAPI CXX (icpx) compiler.") options.append("--with-sycl=1") options.append("--with-syclc=" + self.compiler.cxx)