diff --git a/src/rez/package_filter.py b/src/rez/package_filter.py index 049867ba0..c6e64fb5c 100644 --- a/src/rez/package_filter.py +++ b/src/rez/package_filter.py @@ -369,11 +369,12 @@ def parse_rule(cls, txt): Returns: Rule: """ - types = {"glob": GlobRule, - "regex": RegexRule, - "range": RangeRule, - "before": TimestampRule, - "after": TimestampRule} + types: dict[str, type[Rule]] = { + "glob": GlobRule, + "regex": RegexRule, + "range": RangeRule, + "before": TimestampRule, + "after": TimestampRule} # parse form 'x(y)' into x, y label, txt = Rule._parse_label(txt) @@ -440,7 +441,7 @@ def cost(self): return 10 @classmethod - def _parse(cls, txt): + def _parse(cls, txt: str): _, txt = Rule._parse_label(txt) return cls(txt) diff --git a/src/rez/package_maker.py b/src/rez/package_maker.py index 6c4aa5eda..3b3b94069 100644 --- a/src/rez/package_maker.py +++ b/src/rez/package_maker.py @@ -20,6 +20,7 @@ from rez.version import Version from contextlib import contextmanager import os +from typing import Iterable # this schema will automatically harden request strings like 'python-*'; see @@ -200,19 +201,20 @@ def make_package(name, path, make_base=None, make_root=None, skip_existing=True, # package = maker.get_package() - src_variants: list[Variant] = [] # skip those variants that already exist if skip_existing: + variants: list[Variant] = [] for variant in package.iter_variants(): variant_ = variant.install(path, dry_run=True) if variant_ is None: - src_variants.append(variant) + variants.append(variant) else: maker.skipped_variants.append(variant_) if warn_on_skip: print_warning("Skipping installation: Package variant already " "exists: %s" % variant_.uri) + src_variants: Iterable[Variant] = variants else: src_variants = package.iter_variants() diff --git a/src/rez/resolved_context.py b/src/rez/resolved_context.py index 5008ce92d..29f58fa7a 100644 --- a/src/rez/resolved_context.py +++ b/src/rez/resolved_context.py @@ -734,7 +734,7 @@ def read_from_buffer(cls, buf, identifier_str=None): except Exception as e: cls._load_error(e, identifier_str) - def get_resolve_diff(self, other): + def get_resolve_diff(self, other: ResolvedContext): """Get the difference between the resolve in this context and another. The difference is described from the point of view of the current context diff --git a/src/rez/rex.py b/src/rez/rex.py index 42282d2a9..c7dcad6a5 100644 --- a/src/rez/rex.py +++ b/src/rez/rex.py @@ -13,6 +13,7 @@ from contextlib import contextmanager from string import Formatter from collections.abc import MutableMapping +from typing import Iterable from rez.system import system from rez.config import config @@ -178,7 +179,7 @@ class ActionManager(object): triggers the callbacks of the `ActionInterpreter`. """ def __init__(self, interpreter: ActionInterpreter, parent_environ: dict[str, str] | None = None, - parent_variables=None, formatter=None, verbose=False, env_sep_map=None): + parent_variables: Iterable[str] | None = None, formatter=None, verbose=False, env_sep_map=None): ''' interpreter: string or `ActionInterpreter` the interpreter to use when executing rex actions diff --git a/src/rez/shells.py b/src/rez/shells.py index 343280af6..03d27a057 100644 --- a/src/rez/shells.py +++ b/src/rez/shells.py @@ -36,7 +36,7 @@ def get_shell_types() -> list[str]: return list(plugin_manager.get_plugins('shell')) -def get_shell_class(shell=None) -> type[Shell]: +def get_shell_class(shell: str | None = None) -> type[Shell]: """Get the plugin class associated with the given or current shell. Returns: @@ -47,9 +47,9 @@ def get_shell_class(shell=None) -> type[Shell]: if not shell: from rez.system import system shell = system.shell - + assert shell is not None from rez.plugin_managers import plugin_manager - return plugin_manager.get_plugin_class("shell", shell, type=Shell) + return plugin_manager.get_plugin_class("shell", shell, Shell) def create_shell(shell: str | None = None, **kwargs) -> Shell: @@ -335,7 +335,7 @@ class UnixShell(Shell): command_arg = '-c' stdin_arg = '-s' last_command_status = '$?' - syspaths = None + syspaths: list[str] = None # # startup rules diff --git a/src/rez/suite.py b/src/rez/suite.py index 1a6c1ff89..5b0f44148 100644 --- a/src/rez/suite.py +++ b/src/rez/suite.py @@ -39,6 +39,10 @@ class Context(TypedDict): hidden_tools: set[str] priority: int prefix_char: str | None + loaded: bool + prefix: str + suffix: str + else: Tool = dict Context = dict diff --git a/src/rezplugins/release_hook/amqp.py b/src/rezplugins/release_hook/amqp.py index cb3cefc3f..2d6c25e0f 100644 --- a/src/rezplugins/release_hook/amqp.py +++ b/src/rezplugins/release_hook/amqp.py @@ -5,10 +5,13 @@ """ Publishes a message to the broker. """ +from __future__ import annotations + from rez.release_hook import ReleaseHook from rez.utils.logging_ import print_error, print_debug from rez.utils.amqp import publish_message from rez.config import config +from typing import Any class AmqpReleaseHook(ReleaseHook): @@ -55,7 +58,7 @@ def post_release(self, user, install_path, variants, **kwargs): package = self.package # build the message dict - data = {} + data: dict[str, Any] = {} data["package"] = dict( name=package.name, version=str(package.version),