Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chadrik committed Jul 1, 2024
1 parent 5626dc2 commit 44f4ac3
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 15 deletions.
13 changes: 7 additions & 6 deletions src/rez/package_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 4 additions & 2 deletions src/rez/package_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion src/rez/resolved_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/rez/rex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/rez/shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -335,7 +335,7 @@ class UnixShell(Shell):
command_arg = '-c'
stdin_arg = '-s'
last_command_status = '$?'
syspaths = None
syspaths: list[str] = None

#
# startup rules
Expand Down
4 changes: 4 additions & 0 deletions src/rez/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/rezplugins/release_hook/amqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 44f4ac3

Please sign in to comment.