Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commodore/component/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path as P
from typing import Optional

import _gojsonnet
import _gojsonnet # type: ignore
import click
import git

Expand Down
3 changes: 2 additions & 1 deletion commodore/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class Config:
_github_token: Optional[str]
_request_timeout: int
_managed_tools: dict[str, str]
_api_token: Optional[str]

oidc_client: Optional[str]
oidc_discovery_url: Optional[str]
Expand Down Expand Up @@ -240,7 +241,7 @@ def api_token(self, api_token):
api_token = apitoken.read()
except OSError as e:
# File name too long, assume token is not configured as file
if "File name too long" in e.strerror:
if e.strerror and "File name too long" in e.strerror:
pass
else:
raise
Expand Down
20 changes: 13 additions & 7 deletions commodore/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from collections.abc import Callable, Iterable
from datetime import datetime
from pathlib import Path as P
from typing import Optional
from typing import Optional, overload

import click
import requests
Expand All @@ -19,12 +19,12 @@

# pylint: disable=redefined-builtin
from requests.exceptions import ConnectionError, HTTPError
from kapitan import cached
from kapitan import targets as kapitan_targets
from kapitan import defaults
from kapitan.cached import reset_cache as reset_reclass_cache
from kapitan.refs.base import RefController, PlainRef
from kapitan.refs.secrets.vaultkv import VaultBackend
from kapitan import cached # type: ignore
from kapitan import targets as kapitan_targets # type: ignore
from kapitan import defaults # type: ignore
from kapitan.cached import reset_cache as reset_reclass_cache # type: ignore
from kapitan.refs.base import RefController, PlainRef # type: ignore
from kapitan.refs.secrets.vaultkv import VaultBackend # type: ignore

from reclass_rs import Reclass

Expand Down Expand Up @@ -377,6 +377,12 @@ def python3_executable() -> str:
return path_python


@overload
def cpu_count(fallback: int) -> int: ...
@overload
def cpu_count(fallback: Optional[int] = None) -> Optional[int]: ...


def cpu_count(fallback: Optional[int] = None) -> Optional[int]:
"""Return the number of available CPU cores or `fallback` if CPU count can't be determined.

Expand Down
2 changes: 1 addition & 1 deletion commodore/multi_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def deregister_package(self, name: str):
except KeyError as e:
raise ValueError(f"can't deregister unknown package {name}") from e

def checkout_package(self, name: str, version: str):
def checkout_package(self, name: str, version: Optional[str]):
"""Create or update worktree for package `name`."""
target_dir = self.get_package(name)
if not target_dir:
Expand Down
2 changes: 1 addition & 1 deletion commodore/postprocess/builtin_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pathlib import Path as P

import _gojsonnet
import _gojsonnet # type: ignore

import click

Expand Down
2 changes: 1 addition & 1 deletion commodore/postprocess/jsonnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pathlib import Path as P
from typing import Any

import _gojsonnet
import _gojsonnet # type: ignore

from commodore.config import Config
from commodore.component import Component
Expand Down
2 changes: 2 additions & 0 deletions commodore/refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
from base64 import b64encode
from pathlib import Path as P
from typing import Optional

import click

Expand Down Expand Up @@ -92,6 +93,7 @@ class RefBuilder:
"""

_refs: dict[str, SecretRef]
_ref_params: Optional[dict[str, dict]]

def __init__(self, config: Config, inventory):
self.debug = config.debug
Expand Down
2 changes: 1 addition & 1 deletion commodore/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from commodore import tools
from commodore.config import Config

from pygobuildinfo import get_go_build_info
from pygobuildinfo import get_go_build_info # type: ignore


def _native_find_so(dep) -> os.PathLike[str]:
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ deps =
mypy
types-PyYAML
types-requests
types-pyxdg
types-oauthlib
commands =
# We ignore missing imports since some of our dependencies do not have type information.
# Someday, it might be useful to try and import headers for them. ~chrisglass
mypy --ignore-missing-imports --show-error-codes {toxinidir}/commodore
mypy --check-untyped-defs --show-error-codes {toxinidir}/commodore

[testenv:black]
description = Ensure black formatting is applied
Expand Down