2f800b2a75841f37e5ffa2b7f50deaed3137cc10
Marco Ricci Change the author e-mail ad...

Marco Ricci authored 3 months ago

src/derivepassphrase/_types.py   1) # SPDX-FileCopyrightText: 2024 Marco Ricci <software@the13thletter.info>
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py    2) #
src/derivepassphrase/types.py    3) # SPDX-License-Identifier: MIT
src/derivepassphrase/types.py    4) 
Marco Ricci Update documentation to use...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py   5) """Types used by derivepassphrase."""
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py    6) 
src/derivepassphrase/types.py    7) from __future__ import annotations
src/derivepassphrase/types.py    8) 
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py   9) import enum
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py  10) from typing import TYPE_CHECKING
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 5 months ago

src/derivepassphrase/types.py   11) 
Marco Ricci Support Python 3.10 and PyP...

Marco Ricci authored 5 months ago

src/derivepassphrase/types.py   12) from typing_extensions import (
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py  13)     NamedTuple,
Marco Ricci Fix style issues with ruff...

Marco Ricci authored 5 months ago

src/derivepassphrase/types.py   14)     NotRequired,
src/derivepassphrase/types.py   15)     TypedDict,
Marco Ricci Support Python 3.10 and PyP...

Marco Ricci authored 5 months ago

src/derivepassphrase/types.py   16) )
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py   17) 
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py  18) if TYPE_CHECKING:
src/derivepassphrase/_types.py  19)     from collections.abc import Sequence
src/derivepassphrase/_types.py  20)     from typing import Literal
src/derivepassphrase/_types.py  21) 
src/derivepassphrase/_types.py  22)     from typing_extensions import (
src/derivepassphrase/_types.py  23)         Any,
src/derivepassphrase/_types.py  24)         Required,
src/derivepassphrase/_types.py  25)         TypeIs,
src/derivepassphrase/_types.py  26)     )
src/derivepassphrase/_types.py  27) 
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py  28) __all__ = (
src/derivepassphrase/_types.py  29)     'SSH_AGENT',
src/derivepassphrase/_types.py  30)     'SSH_AGENTC',
src/derivepassphrase/_types.py  31)     'KeyCommentPair',
src/derivepassphrase/_types.py  32)     'VaultConfig',
src/derivepassphrase/_types.py  33)     'is_vault_config',
src/derivepassphrase/_types.py  34) )
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py   35) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

src/derivepassphrase/types.py   36) 
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py   37) class VaultConfigGlobalSettings(TypedDict, total=False):
src/derivepassphrase/types.py   38)     r"""Configuration for vault: global settings.
src/derivepassphrase/types.py   39) 
src/derivepassphrase/types.py   40)     Attributes:
src/derivepassphrase/types.py   41)         key:
src/derivepassphrase/types.py   42)             The base64-encoded ssh public key to use, overriding the
src/derivepassphrase/types.py   43)             master passphrase. Optional.
src/derivepassphrase/types.py   44)         phrase:
src/derivepassphrase/types.py   45)             The master passphrase. Optional.
Marco Ricci Allow all textual strings,...

Marco Ricci authored 3 months ago

src/derivepassphrase/_types.py  46)         unicode_normalization_form:
src/derivepassphrase/_types.py  47)             The preferred Unicode normalization form; we warn the user
src/derivepassphrase/_types.py  48)             if textual passphrases do not match their normalized forms.
src/derivepassphrase/_types.py  49)             Optional, and a `derivepassphrase` extension.
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py   50) 
src/derivepassphrase/types.py   51)     """
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

src/derivepassphrase/types.py   52) 
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py   53)     key: NotRequired[str]
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py  54)     """"""
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py   55)     phrase: NotRequired[str]
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py  56)     """"""
Marco Ricci Allow all textual strings,...

Marco Ricci authored 3 months ago

src/derivepassphrase/_types.py  57)     unicode_normalization_form: NotRequired[
src/derivepassphrase/_types.py  58)         Literal['NFC', 'NFD', 'NFKC', 'NFKD']
src/derivepassphrase/_types.py  59)     ]
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py  60)     """"""
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py   61) 
src/derivepassphrase/types.py   62) 
src/derivepassphrase/types.py   63) class VaultConfigServicesSettings(VaultConfigGlobalSettings, total=False):
src/derivepassphrase/types.py   64)     r"""Configuration for vault: services settings.
src/derivepassphrase/types.py   65) 
src/derivepassphrase/types.py   66)     Attributes:
src/derivepassphrase/types.py   67)         notes:
src/derivepassphrase/types.py   68)             Optional notes for this service, to display to the user when
src/derivepassphrase/types.py   69)             generating the passphrase.
src/derivepassphrase/types.py   70)         length:
src/derivepassphrase/types.py   71)             Desired passphrase length.
src/derivepassphrase/types.py   72)         repeat:
src/derivepassphrase/types.py   73)             The maximum number of immediate character repetitions
src/derivepassphrase/types.py   74)             allowed in the passphrase.  Disabled if set to 0.
src/derivepassphrase/types.py   75)         lower:
src/derivepassphrase/types.py   76)             Optional constraint on ASCII lowercase characters.  If
src/derivepassphrase/types.py   77)             positive, include this many lowercase characters
src/derivepassphrase/types.py   78)             somewhere in the passphrase.  If 0, avoid lowercase
src/derivepassphrase/types.py   79)             characters altogether.
src/derivepassphrase/types.py   80)         upper:
src/derivepassphrase/types.py   81)             Same as `lower`, but for ASCII uppercase characters.
src/derivepassphrase/types.py   82)         number:
src/derivepassphrase/types.py   83)             Same as `lower`, but for ASCII digits.
src/derivepassphrase/types.py   84)         space:
src/derivepassphrase/types.py   85)             Same as `lower`, but for the space character.
src/derivepassphrase/types.py   86)         dash:
src/derivepassphrase/types.py   87)             Same as `lower`, but for the hyphen-minus and underscore
src/derivepassphrase/types.py   88)             characters.
src/derivepassphrase/types.py   89)         symbol:
src/derivepassphrase/types.py   90)             Same as `lower`, but for all other hitherto unlisted
src/derivepassphrase/types.py   91)             ASCII printable characters (except backquote).
src/derivepassphrase/types.py   92) 
src/derivepassphrase/types.py   93)     """
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

src/derivepassphrase/types.py   94) 
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py   95)     notes: NotRequired[str]
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py  96)     """"""
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py   97)     length: NotRequired[int]
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py  98)     """"""
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py   99)     repeat: NotRequired[int]
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 100)     """"""
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  101)     lower: NotRequired[int]
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 102)     """"""
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  103)     upper: NotRequired[int]
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 104)     """"""
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  105)     number: NotRequired[int]
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 106)     """"""
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  107)     space: NotRequired[int]
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 108)     """"""
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  109)     dash: NotRequired[int]
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 110)     """"""
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  111)     symbol: NotRequired[int]
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 112)     """"""
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  113) 
src/derivepassphrase/types.py  114) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

src/derivepassphrase/types.py  115) _VaultConfig = TypedDict(
src/derivepassphrase/types.py  116)     '_VaultConfig',
src/derivepassphrase/types.py  117)     {'global': NotRequired[VaultConfigGlobalSettings]},
src/derivepassphrase/types.py  118)     total=False,
src/derivepassphrase/types.py  119) )
src/derivepassphrase/types.py  120) 
src/derivepassphrase/types.py  121) 
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  122) class VaultConfig(TypedDict, _VaultConfig, total=False):
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 123)     r"""Configuration for vault.  For typing purposes.
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  124) 
src/derivepassphrase/types.py  125)     Usually stored as JSON.
src/derivepassphrase/types.py  126) 
src/derivepassphrase/types.py  127)     Attributes:
src/derivepassphrase/types.py  128)         global (NotRequired[VaultConfigGlobalSettings]):
src/derivepassphrase/types.py  129)             Global settings.
src/derivepassphrase/types.py  130)         services (Required[dict[str, VaultConfigServicesSettings]]):
src/derivepassphrase/types.py  131)             Service-specific settings.
src/derivepassphrase/types.py  132) 
src/derivepassphrase/types.py  133)     """
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

src/derivepassphrase/types.py  134) 
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  135)     services: Required[dict[str, VaultConfigServicesSettings]]
src/derivepassphrase/types.py  136) 
Marco Ricci Reformat everything with ruff

Marco Ricci authored 5 months ago

src/derivepassphrase/types.py  137) 
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 138) def validate_vault_config(  # noqa: C901,PLR0912,PLR0915
src/derivepassphrase/_types.py 139)     obj: Any,  # noqa: ANN401
src/derivepassphrase/_types.py 140)     /,
src/derivepassphrase/_types.py 141)     *,
src/derivepassphrase/_types.py 142)     allow_unknown_settings: bool = False,
src/derivepassphrase/_types.py 143)     allow_derivepassphrase_extensions: bool = False,
src/derivepassphrase/_types.py 144) ) -> None:
src/derivepassphrase/_types.py 145)     """Check that `obj` is a valid vault config.
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  146) 
src/derivepassphrase/types.py  147)     Args:
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 148)         obj:
src/derivepassphrase/_types.py 149)             The object to test.
src/derivepassphrase/_types.py 150)         allow_unknown_settings:
src/derivepassphrase/_types.py 151)             If false, abort on unknown settings.
src/derivepassphrase/_types.py 152)         allow_derivepassphrase_extensions:
src/derivepassphrase/_types.py 153)             If true, allow `derivepassphrase` extensions.
src/derivepassphrase/_types.py 154) 
src/derivepassphrase/_types.py 155)     Raises:
src/derivepassphrase/_types.py 156)         TypeError:
src/derivepassphrase/_types.py 157)             An entry in the vault config, or the vault config itself,
src/derivepassphrase/_types.py 158)             has the wrong type.
src/derivepassphrase/_types.py 159)         ValueError:
src/derivepassphrase/_types.py 160)             An entry in the vault config is not allowed, or has a
src/derivepassphrase/_types.py 161)             disallowed value.
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  162) 
src/derivepassphrase/types.py  163)     """
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 164) 
src/derivepassphrase/_types.py 165)     def as_json_path_string(json_path: Sequence[str], /) -> str:
src/derivepassphrase/_types.py 166)         return ''.join('.' + repr(x) for x in json_path)
src/derivepassphrase/_types.py 167) 
src/derivepassphrase/_types.py 168)     err_obj_not_a_dict = 'vault config is not a dict'
src/derivepassphrase/_types.py 169)     err_non_str_service_name = (
src/derivepassphrase/_types.py 170)         'vault config contains non-string service name {!r}'
src/derivepassphrase/_types.py 171)     )
src/derivepassphrase/_types.py 172) 
src/derivepassphrase/_types.py 173)     def err_not_a_dict(json_path: Sequence[str], /) -> str:
src/derivepassphrase/_types.py 174)         json_path_str = as_json_path_string(json_path)
src/derivepassphrase/_types.py 175)         return f'vault config entry {json_path_str} is not a dict'
src/derivepassphrase/_types.py 176) 
src/derivepassphrase/_types.py 177)     def err_not_a_string(json_path: Sequence[str], /) -> str:
src/derivepassphrase/_types.py 178)         json_path_str = as_json_path_string(json_path)
src/derivepassphrase/_types.py 179)         return f'vault config entry {json_path_str} is not a string'
src/derivepassphrase/_types.py 180) 
src/derivepassphrase/_types.py 181)     def err_not_an_int(json_path: Sequence[str], /) -> str:
src/derivepassphrase/_types.py 182)         json_path_str = as_json_path_string(json_path)
src/derivepassphrase/_types.py 183)         return f'vault config entry {json_path_str} is not an integer'
src/derivepassphrase/_types.py 184) 
src/derivepassphrase/_types.py 185)     err_key_and_phrase = (
src/derivepassphrase/_types.py 186)         '"key" and "phrase" specified on the same vault config level'
src/derivepassphrase/_types.py 187)     )
src/derivepassphrase/_types.py 188) 
src/derivepassphrase/_types.py 189)     def err_derivepassphrase_extension(
src/derivepassphrase/_types.py 190)         key: str, json_path: Sequence[str], /
src/derivepassphrase/_types.py 191)     ) -> str:
src/derivepassphrase/_types.py 192)         json_path_str = as_json_path_string(json_path)
src/derivepassphrase/_types.py 193)         return (
src/derivepassphrase/_types.py 194)             f'vault config entry {json_path_str} uses '
src/derivepassphrase/_types.py 195)             f'`derivepassphrase` extension {key!r}'
src/derivepassphrase/_types.py 196)         )
src/derivepassphrase/_types.py 197) 
src/derivepassphrase/_types.py 198)     def err_unknown_setting(key: str, json_path: Sequence[str], /) -> str:
src/derivepassphrase/_types.py 199)         json_path_str = as_json_path_string(json_path)
src/derivepassphrase/_types.py 200)         return (
src/derivepassphrase/_types.py 201)             f'vault config entry {json_path_str} uses '
src/derivepassphrase/_types.py 202)             f'unknown setting {key!r}'
src/derivepassphrase/_types.py 203)         )
src/derivepassphrase/_types.py 204) 
src/derivepassphrase/_types.py 205)     def err_bad_number(
src/derivepassphrase/_types.py 206)         key: str,
src/derivepassphrase/_types.py 207)         json_path: Sequence[str],
src/derivepassphrase/_types.py 208)         /,
src/derivepassphrase/_types.py 209)         *,
src/derivepassphrase/_types.py 210)         strictly_positive: bool = False,
src/derivepassphrase/_types.py 211)     ) -> str:
src/derivepassphrase/_types.py 212)         json_path_str = as_json_path_string((*json_path, key))
src/derivepassphrase/_types.py 213)         return f'vault config entry {json_path_str} is ' + (
src/derivepassphrase/_types.py 214)             'not positive' if strictly_positive else 'negative'
src/derivepassphrase/_types.py 215)         )
src/derivepassphrase/_types.py 216) 
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  217)     if not isinstance(obj, dict):
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 218)         raise TypeError(err_obj_not_a_dict)
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  219)     if 'global' in obj:
src/derivepassphrase/types.py  220)         o_global = obj['global']
src/derivepassphrase/types.py  221)         if not isinstance(o_global, dict):
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 222)             raise TypeError(err_not_a_dict(['global']))
src/derivepassphrase/_types.py 223)         for key, value in o_global.items():
src/derivepassphrase/_types.py 224)             match key:
src/derivepassphrase/_types.py 225)                 case 'key' | 'phrase':
src/derivepassphrase/_types.py 226)                     if not isinstance(value, str):
src/derivepassphrase/_types.py 227)                         raise TypeError(err_not_a_dict(['global', key]))
src/derivepassphrase/_types.py 228)                 case 'unicode_normalization_form':
src/derivepassphrase/_types.py 229)                     if not isinstance(value, str):
src/derivepassphrase/_types.py 230)                         raise TypeError(err_not_a_dict(['global', key]))
src/derivepassphrase/_types.py 231)                     if not allow_derivepassphrase_extensions:
src/derivepassphrase/_types.py 232)                         raise ValueError(
src/derivepassphrase/_types.py 233)                             err_derivepassphrase_extension(key, ('global',))
src/derivepassphrase/_types.py 234)                         )
src/derivepassphrase/_types.py 235)                 case _ if not allow_unknown_settings:
src/derivepassphrase/_types.py 236)                     raise ValueError(err_unknown_setting(key, ('global',)))
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  237)         if 'key' in o_global and 'phrase' in o_global:
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 238)             raise ValueError(err_key_and_phrase)
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  239)     if not isinstance(obj.get('services'), dict):
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 240)         raise TypeError(err_not_a_dict(['services']))
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  241)     for sv_name, service in obj['services'].items():
src/derivepassphrase/types.py  242)         if not isinstance(sv_name, str):
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 243)             raise TypeError(err_non_str_service_name.format(sv_name))
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  244)         if not isinstance(service, dict):
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 245)             raise TypeError(err_not_a_dict(['services', sv_name]))
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  246)         for key, value in service.items():
src/derivepassphrase/types.py  247)             match key:
src/derivepassphrase/types.py  248)                 case 'notes' | 'phrase' | 'key':
src/derivepassphrase/types.py  249)                     if not isinstance(value, str):
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 250)                         raise TypeError(
src/derivepassphrase/_types.py 251)                             err_not_a_string(['services', sv_name, key])
src/derivepassphrase/_types.py 252)                         )
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  253)                 case 'length':
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 254)                     if not isinstance(value, int):
src/derivepassphrase/_types.py 255)                         raise TypeError(
src/derivepassphrase/_types.py 256)                             err_not_an_int(['services', sv_name, key])
src/derivepassphrase/_types.py 257)                         )
src/derivepassphrase/_types.py 258)                     if value < 1:
src/derivepassphrase/_types.py 259)                         raise ValueError(
src/derivepassphrase/_types.py 260)                             err_bad_number(
src/derivepassphrase/_types.py 261)                                 key,
src/derivepassphrase/_types.py 262)                                 ['services', sv_name],
src/derivepassphrase/_types.py 263)                                 strictly_positive=True,
src/derivepassphrase/_types.py 264)                             )
src/derivepassphrase/_types.py 265)                         )
src/derivepassphrase/_types.py 266)                 case (
src/derivepassphrase/_types.py 267)                     'repeat'
src/derivepassphrase/_types.py 268)                     | 'lower'
src/derivepassphrase/_types.py 269)                     | 'upper'
src/derivepassphrase/_types.py 270)                     | 'number'
src/derivepassphrase/_types.py 271)                     | 'space'
src/derivepassphrase/_types.py 272)                     | 'dash'
src/derivepassphrase/_types.py 273)                     | 'symbol'
src/derivepassphrase/_types.py 274)                 ):
src/derivepassphrase/_types.py 275)                     if not isinstance(value, int):
src/derivepassphrase/_types.py 276)                         raise TypeError(
src/derivepassphrase/_types.py 277)                             err_not_an_int(['services', sv_name, key])
src/derivepassphrase/_types.py 278)                         )
src/derivepassphrase/_types.py 279)                     if value < 0:
src/derivepassphrase/_types.py 280)                         raise ValueError(
src/derivepassphrase/_types.py 281)                             err_bad_number(
src/derivepassphrase/_types.py 282)                                 key,
src/derivepassphrase/_types.py 283)                                 ['services', sv_name],
src/derivepassphrase/_types.py 284)                                 strictly_positive=False,
src/derivepassphrase/_types.py 285)                             )
src/derivepassphrase/_types.py 286)                         )
src/derivepassphrase/_types.py 287)                 case _ if not allow_unknown_settings:
src/derivepassphrase/_types.py 288)                     raise ValueError(
src/derivepassphrase/_types.py 289)                         err_unknown_setting(key, ['services', sv_name])
src/derivepassphrase/_types.py 290)                     )
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  291)         if 'key' in service and 'phrase' in service:
Marco Ricci Overhaul the validation fun...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 292)             raise ValueError(err_key_and_phrase)
src/derivepassphrase/_types.py 293) 
src/derivepassphrase/_types.py 294) 
src/derivepassphrase/_types.py 295) def is_vault_config(obj: Any) -> TypeIs[VaultConfig]:  # noqa: ANN401
src/derivepassphrase/_types.py 296)     """Check if `obj` is a valid vault config, according to typing.
src/derivepassphrase/_types.py 297) 
src/derivepassphrase/_types.py 298)     Args:
src/derivepassphrase/_types.py 299)         obj: The object to test.
src/derivepassphrase/_types.py 300) 
src/derivepassphrase/_types.py 301)     Returns:
src/derivepassphrase/_types.py 302)         True if this is a vault config, false otherwise.
src/derivepassphrase/_types.py 303) 
src/derivepassphrase/_types.py 304)     """
src/derivepassphrase/_types.py 305)     try:
src/derivepassphrase/_types.py 306)         validate_vault_config(
src/derivepassphrase/_types.py 307)             obj,
src/derivepassphrase/_types.py 308)             allow_unknown_settings=True,
src/derivepassphrase/_types.py 309)             allow_derivepassphrase_extensions=True,
src/derivepassphrase/_types.py 310)         )
src/derivepassphrase/_types.py 311)     except (TypeError, ValueError) as exc:
src/derivepassphrase/_types.py 312)         if 'vault config ' not in str(exc):  # pragma: no cover
src/derivepassphrase/_types.py 313)             raise  # noqa: DOC501
src/derivepassphrase/_types.py 314)         return False
Marco Ricci Move typing classes into se...

Marco Ricci authored 6 months ago

src/derivepassphrase/types.py  315)     return True
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 316) 
src/derivepassphrase/_types.py 317) 
src/derivepassphrase/_types.py 318) class KeyCommentPair(NamedTuple):
src/derivepassphrase/_types.py 319)     """SSH key plus comment pair.  For typing purposes.
src/derivepassphrase/_types.py 320) 
src/derivepassphrase/_types.py 321)     Attributes:
src/derivepassphrase/_types.py 322)         key: SSH key.
src/derivepassphrase/_types.py 323)         comment: SSH key comment.
src/derivepassphrase/_types.py 324) 
src/derivepassphrase/_types.py 325)     """
src/derivepassphrase/_types.py 326) 
src/derivepassphrase/_types.py 327)     key: bytes | bytearray
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 328)     """"""
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 329)     comment: bytes | bytearray
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 330)     """"""
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 331) 
src/derivepassphrase/_types.py 332) 
src/derivepassphrase/_types.py 333) class SSH_AGENTC(enum.Enum):  # noqa: N801
src/derivepassphrase/_types.py 334)     """SSH agent protocol numbers: client requests.
src/derivepassphrase/_types.py 335) 
src/derivepassphrase/_types.py 336)     Attributes:
src/derivepassphrase/_types.py 337)         REQUEST_IDENTITIES:
Marco Ricci Generate nicer documentatio...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 338)             List identities.  Expecting
src/derivepassphrase/_types.py 339)             [`SSH_AGENT.IDENTITIES_ANSWER`][].
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 340)         SIGN_REQUEST:
Marco Ricci Generate nicer documentatio...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 341)             Sign data.  Expecting [`SSH_AGENT.SIGN_RESPONSE`][].
Marco Ricci Add principal support for u...

Marco Ricci authored 3 months ago

src/derivepassphrase/_types.py 342)         ADD_IDENTITY:
src/derivepassphrase/_types.py 343)             Add an (SSH2) identity.
src/derivepassphrase/_types.py 344)         REMOVE_IDENTITY:
src/derivepassphrase/_types.py 345)             Remove an (SSH2) identity.
src/derivepassphrase/_types.py 346)         ADD_ID_CONSTRAINED:
src/derivepassphrase/_types.py 347)             Add an (SSH2) identity, including key constraints.
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 348) 
src/derivepassphrase/_types.py 349)     """
src/derivepassphrase/_types.py 350) 
src/derivepassphrase/_types.py 351)     REQUEST_IDENTITIES: int = 11
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 352)     """"""
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 353)     SIGN_REQUEST: int = 13
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 354)     """"""
Marco Ricci Add principal support for u...

Marco Ricci authored 3 months ago

src/derivepassphrase/_types.py 355)     ADD_IDENTITY: int = 17
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 356)     """"""
Marco Ricci Add principal support for u...

Marco Ricci authored 3 months ago

src/derivepassphrase/_types.py 357)     REMOVE_IDENTITY: int = 18
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 358)     """"""
Marco Ricci Add principal support for u...

Marco Ricci authored 3 months ago

src/derivepassphrase/_types.py 359)     ADD_ID_CONSTRAINED: int = 25
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 360)     """"""
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 361) 
src/derivepassphrase/_types.py 362) 
src/derivepassphrase/_types.py 363) class SSH_AGENT(enum.Enum):  # noqa: N801
src/derivepassphrase/_types.py 364)     """SSH agent protocol numbers: server replies.
src/derivepassphrase/_types.py 365) 
src/derivepassphrase/_types.py 366)     Attributes:
Marco Ricci Add a specific error class...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 367)         FAILURE:
src/derivepassphrase/_types.py 368)             Generic failure code.
src/derivepassphrase/_types.py 369)         SUCCESS:
src/derivepassphrase/_types.py 370)             Generic success code.
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 371)         IDENTITIES_ANSWER:
Marco Ricci Generate nicer documentatio...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 372)             Successful answer to [`SSH_AGENTC.REQUEST_IDENTITIES`][].
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 373)         SIGN_RESPONSE:
Marco Ricci Generate nicer documentatio...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 374)             Successful answer to [`SSH_AGENTC.SIGN_REQUEST`][].
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 375) 
src/derivepassphrase/_types.py 376)     """
src/derivepassphrase/_types.py 377) 
Marco Ricci Add a specific error class...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 378)     FAILURE: int = 5
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 379)     """"""
Marco Ricci Add a specific error class...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 380)     SUCCESS: int = 6
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 381)     """"""
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 382)     IDENTITIES_ANSWER: int = 12
Marco Ricci Enable cross-references on...

Marco Ricci authored 2 months ago

src/derivepassphrase/_types.py 383)     """"""
Marco Ricci Consolidate `types` submodu...

Marco Ricci authored 4 months ago

src/derivepassphrase/_types.py 384)     SIGN_RESPONSE: int = 14