keep-github-workflows-active 2.3.2__py3-none-any.whl → 2.3.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- keep_github_workflows_active/__init__.py +1 -1
- keep_github_workflows_active/__init__conf__.py +4 -2
- keep_github_workflows_active/__main__.py +9 -6
- keep_github_workflows_active/behaviors.py +5 -7
- keep_github_workflows_active/cli.py +28 -28
- keep_github_workflows_active/keep_github_workflow_active.py +13 -10
- keep_github_workflows_active/sanitization.py +19 -12
- keep_github_workflows_active/typed_click.py +31 -12
- {keep_github_workflows_active-2.3.2.dist-info → keep_github_workflows_active-2.3.3.dist-info}/METADATA +8 -8
- keep_github_workflows_active-2.3.3.dist-info/RECORD +15 -0
- {keep_github_workflows_active-2.3.2.dist-info → keep_github_workflows_active-2.3.3.dist-info}/WHEEL +1 -1
- keep_github_workflows_active-2.3.2.dist-info/RECORD +0 -15
- {keep_github_workflows_active-2.3.2.dist-info → keep_github_workflows_active-2.3.3.dist-info}/entry_points.txt +0 -0
- {keep_github_workflows_active-2.3.2.dist-info → keep_github_workflows_active-2.3.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
from .__init__conf__ import print_info
|
|
5
6
|
from .behaviors import (
|
|
6
7
|
CANONICAL_GREETING,
|
|
7
8
|
emit_greeting,
|
|
8
9
|
noop_main,
|
|
9
10
|
raise_intentional_failure,
|
|
10
11
|
)
|
|
11
|
-
from .__init__conf__ import print_info
|
|
12
12
|
|
|
13
13
|
__all__ = [
|
|
14
14
|
"CANONICAL_GREETING",
|
|
@@ -19,12 +19,14 @@ present authoritative project information without invoking packaging APIs.
|
|
|
19
19
|
|
|
20
20
|
from __future__ import annotations
|
|
21
21
|
|
|
22
|
+
import sys
|
|
23
|
+
|
|
22
24
|
#: Distribution name declared in ``pyproject.toml``.
|
|
23
25
|
name = "keep_github_workflows_active"
|
|
24
26
|
#: Human-readable summary shown in CLI help output.
|
|
25
27
|
title = "Template for python apps with registered cli commands"
|
|
26
28
|
#: Current release version pulled from ``pyproject.toml`` by automation.
|
|
27
|
-
version = "2.3.
|
|
29
|
+
version = "2.3.3"
|
|
28
30
|
#: Repository homepage presented to users.
|
|
29
31
|
homepage = "https://github.com/bitranox/keep_github_workflows_active"
|
|
30
32
|
#: Author attribution surfaced in CLI output.
|
|
@@ -71,4 +73,4 @@ def print_info() -> None:
|
|
|
71
73
|
pad = max(len(label) for label, _ in fields)
|
|
72
74
|
lines = [f"Info for {name}:", ""]
|
|
73
75
|
lines.extend(f" {label.ljust(pad)} = {value}" for label, value in fields)
|
|
74
|
-
|
|
76
|
+
sys.stdout.write("\n".join(lines) + "\n")
|
|
@@ -9,10 +9,10 @@ installed console script, including traceback handling and exit-code mapping.
|
|
|
9
9
|
|
|
10
10
|
Contents
|
|
11
11
|
--------
|
|
12
|
-
* :func:`_open_cli_session`
|
|
13
|
-
* :func:`_command_to_run` / :func:`_command_name`
|
|
12
|
+
* :func:`_open_cli_session` - wires ``cli_session`` with the agreed limits.
|
|
13
|
+
* :func:`_command_to_run` / :func:`_command_name` - expose the command and label
|
|
14
14
|
used by the module entry.
|
|
15
|
-
* :func:`_module_main`
|
|
15
|
+
* :func:`_module_main` - drives execution and returns the exit code.
|
|
16
16
|
|
|
17
17
|
System Role
|
|
18
18
|
-----------
|
|
@@ -24,14 +24,17 @@ documented in ``docs/systemdesign/module_reference.md``.
|
|
|
24
24
|
from __future__ import annotations
|
|
25
25
|
|
|
26
26
|
from collections.abc import Callable
|
|
27
|
-
from
|
|
28
|
-
from typing import Final
|
|
27
|
+
from typing import TYPE_CHECKING, Final
|
|
29
28
|
|
|
30
29
|
from lib_cli_exit_tools import cli_session
|
|
31
|
-
import rich_click as click
|
|
32
30
|
|
|
33
31
|
from . import __init__conf__, cli
|
|
34
32
|
|
|
33
|
+
if TYPE_CHECKING:
|
|
34
|
+
from contextlib import AbstractContextManager
|
|
35
|
+
|
|
36
|
+
import rich_click as click
|
|
37
|
+
|
|
35
38
|
# Match the CLI defaults so truncation behaviour stays consistent across entry
|
|
36
39
|
# points regardless of whether users call the console script or ``python -m``.
|
|
37
40
|
#: Character budget for truncated tracebacks when running via module entry.
|
|
@@ -8,11 +8,11 @@ swap in richer logging logic later without touching the transport surface.
|
|
|
8
8
|
|
|
9
9
|
Contents
|
|
10
10
|
--------
|
|
11
|
-
* :func:`emit_greeting`
|
|
11
|
+
* :func:`emit_greeting` - success-path helper that writes the canonical scaffold
|
|
12
12
|
message.
|
|
13
|
-
* :func:`raise_intentional_failure`
|
|
13
|
+
* :func:`raise_intentional_failure` - deterministic error hook used by tests and
|
|
14
14
|
CLI flows to validate traceback handling.
|
|
15
|
-
* :func:`noop_main`
|
|
15
|
+
* :func:`noop_main` - placeholder entry used when callers expect a ``main``
|
|
16
16
|
callable despite the domain layer being stubbed today.
|
|
17
17
|
|
|
18
18
|
System Role
|
|
@@ -24,10 +24,8 @@ features evolve.
|
|
|
24
24
|
|
|
25
25
|
from __future__ import annotations
|
|
26
26
|
|
|
27
|
-
from typing import TextIO
|
|
28
|
-
|
|
29
27
|
import sys
|
|
30
|
-
|
|
28
|
+
from typing import TextIO
|
|
31
29
|
|
|
32
30
|
CANONICAL_GREETING = "Hello World"
|
|
33
31
|
|
|
@@ -140,6 +138,6 @@ def noop_main() -> None:
|
|
|
140
138
|
__all__ = [
|
|
141
139
|
"CANONICAL_GREETING",
|
|
142
140
|
"emit_greeting",
|
|
143
|
-
"raise_intentional_failure",
|
|
144
141
|
"noop_main",
|
|
142
|
+
"raise_intentional_failure",
|
|
145
143
|
]
|
|
@@ -10,23 +10,23 @@ aligned with the Clean Code rules captured in
|
|
|
10
10
|
|
|
11
11
|
Contents
|
|
12
12
|
--------
|
|
13
|
-
* :data:`CLICK_CONTEXT_SETTINGS`
|
|
13
|
+
* :data:`CLICK_CONTEXT_SETTINGS` - shared Click settings ensuring consistent
|
|
14
14
|
``--help`` behavior across commands.
|
|
15
|
-
* :func:`apply_traceback_preferences`
|
|
15
|
+
* :func:`apply_traceback_preferences` - helper that synchronises the shared
|
|
16
16
|
traceback configuration flags.
|
|
17
|
-
* :func:`snapshot_traceback_state` / :func:`restore_traceback_state`
|
|
17
|
+
* :func:`snapshot_traceback_state` / :func:`restore_traceback_state` - utilities
|
|
18
18
|
for preserving and reapplying the global traceback preference.
|
|
19
|
-
* :func:`cli`
|
|
20
|
-
* :func:`cli_main`
|
|
21
|
-
* :func:`cli_info`, :func:`cli_hello`, :func:`cli_fail`
|
|
19
|
+
* :func:`cli` - root command group wiring the global options.
|
|
20
|
+
* :func:`cli_main` - default action when no subcommand is provided.
|
|
21
|
+
* :func:`cli_info`, :func:`cli_hello`, :func:`cli_fail` - subcommands covering
|
|
22
22
|
metadata printing, success path, and failure path.
|
|
23
|
-
* :func:`_record_traceback_choice`, :func:`_announce_traceback_choice`
|
|
23
|
+
* :func:`_record_traceback_choice`, :func:`_announce_traceback_choice` - persist
|
|
24
24
|
traceback preferences across context and shared tooling.
|
|
25
25
|
* :func:`_invoke_cli`, :func:`_current_traceback_mode`, :func:`_traceback_limit`,
|
|
26
|
-
:func:`_print_exception`, :func:`_run_cli_via_exit_tools`
|
|
26
|
+
:func:`_print_exception`, :func:`_run_cli_via_exit_tools` - isolate the error
|
|
27
27
|
handling and delegation path.
|
|
28
|
-
* :func:`_restore_when_requested`
|
|
29
|
-
* :func:`main`
|
|
28
|
+
* :func:`_restore_when_requested` - restores tracebacks when ``main`` finishes.
|
|
29
|
+
* :func:`main` - composition helper delegating to ``lib_cli_exit_tools`` while
|
|
30
30
|
honouring the shared traceback preferences.
|
|
31
31
|
|
|
32
32
|
System Role
|
|
@@ -39,20 +39,20 @@ behaviour remains consistent regardless of entry point.
|
|
|
39
39
|
|
|
40
40
|
from __future__ import annotations
|
|
41
41
|
|
|
42
|
-
from collections.abc import Sequence
|
|
43
42
|
from dataclasses import dataclass
|
|
44
|
-
from typing import Final, NamedTuple
|
|
45
|
-
|
|
46
|
-
import rich_click as click
|
|
47
|
-
from .typed_click import option, version_option
|
|
43
|
+
from typing import TYPE_CHECKING, Final, NamedTuple
|
|
48
44
|
|
|
49
45
|
import lib_cli_exit_tools
|
|
46
|
+
import rich_click as click
|
|
50
47
|
from click.core import ParameterSource
|
|
51
48
|
|
|
52
49
|
from . import __init__conf__
|
|
53
50
|
from . import keep_github_workflow_active as keep_active
|
|
54
51
|
from .behaviors import emit_greeting, noop_main, raise_intentional_failure
|
|
52
|
+
from .typed_click import option, version_option
|
|
55
53
|
|
|
54
|
+
if TYPE_CHECKING:
|
|
55
|
+
from collections.abc import Sequence
|
|
56
56
|
|
|
57
57
|
# =============================================================================
|
|
58
58
|
# Dataclass for typed Click context object
|
|
@@ -95,7 +95,7 @@ def _fallback_token(token: str | None) -> str:
|
|
|
95
95
|
raise click.ClickException(str(exc)) from exc
|
|
96
96
|
|
|
97
97
|
|
|
98
|
-
def apply_traceback_preferences(enabled: bool) -> None:
|
|
98
|
+
def apply_traceback_preferences(*, enabled: bool) -> None:
|
|
99
99
|
"""Synchronise shared traceback flags with the requested preference.
|
|
100
100
|
|
|
101
101
|
Why
|
|
@@ -112,7 +112,7 @@ def apply_traceback_preferences(enabled: bool) -> None:
|
|
|
112
112
|
|
|
113
113
|
Examples
|
|
114
114
|
--------
|
|
115
|
-
>>> apply_traceback_preferences(True)
|
|
115
|
+
>>> apply_traceback_preferences(enabled=True)
|
|
116
116
|
>>> bool(lib_cli_exit_tools.config.traceback)
|
|
117
117
|
True
|
|
118
118
|
>>> bool(lib_cli_exit_tools.config.traceback_force_color)
|
|
@@ -155,7 +155,7 @@ def restore_traceback_state(state: TracebackState) -> None:
|
|
|
155
155
|
Examples
|
|
156
156
|
--------
|
|
157
157
|
>>> prev = snapshot_traceback_state()
|
|
158
|
-
>>> apply_traceback_preferences(True)
|
|
158
|
+
>>> apply_traceback_preferences(enabled=True)
|
|
159
159
|
>>> restore_traceback_state(prev)
|
|
160
160
|
>>> snapshot_traceback_state() == prev
|
|
161
161
|
True
|
|
@@ -192,7 +192,7 @@ def _record_traceback_choice(ctx: click.Context, *, enabled: bool) -> None:
|
|
|
192
192
|
ctx.obj.traceback = enabled
|
|
193
193
|
|
|
194
194
|
|
|
195
|
-
def _announce_traceback_choice(enabled: bool) -> None:
|
|
195
|
+
def _announce_traceback_choice(*, enabled: bool) -> None:
|
|
196
196
|
"""Keep ``lib_cli_exit_tools`` in sync with the selected traceback mode.
|
|
197
197
|
|
|
198
198
|
Why
|
|
@@ -208,7 +208,7 @@ def _announce_traceback_choice(enabled: bool) -> None:
|
|
|
208
208
|
Mutates ``lib_cli_exit_tools.config``.
|
|
209
209
|
"""
|
|
210
210
|
|
|
211
|
-
apply_traceback_preferences(enabled)
|
|
211
|
+
apply_traceback_preferences(enabled=enabled)
|
|
212
212
|
|
|
213
213
|
|
|
214
214
|
def _no_subcommand_requested(ctx: click.Context) -> bool:
|
|
@@ -270,7 +270,7 @@ def _current_traceback_mode() -> bool:
|
|
|
270
270
|
return bool(getattr(lib_cli_exit_tools.config, "traceback", False))
|
|
271
271
|
|
|
272
272
|
|
|
273
|
-
def _traceback_limit(tracebacks_enabled: bool,
|
|
273
|
+
def _traceback_limit(*, tracebacks_enabled: bool, summary_limit: int, verbose_limit: int) -> int:
|
|
274
274
|
"""Return the character budget that matches the current traceback mode.
|
|
275
275
|
|
|
276
276
|
Why
|
|
@@ -379,14 +379,14 @@ def _run_cli_via_exit_tools(
|
|
|
379
379
|
|
|
380
380
|
try:
|
|
381
381
|
return _invoke_cli(argv)
|
|
382
|
-
except BaseException as exc:
|
|
382
|
+
except BaseException as exc:
|
|
383
383
|
tracebacks_enabled = _current_traceback_mode()
|
|
384
|
-
apply_traceback_preferences(tracebacks_enabled)
|
|
384
|
+
apply_traceback_preferences(enabled=tracebacks_enabled)
|
|
385
385
|
return _print_exception(
|
|
386
386
|
exc,
|
|
387
387
|
tracebacks_enabled=tracebacks_enabled,
|
|
388
388
|
length_limit=_traceback_limit(
|
|
389
|
-
tracebacks_enabled,
|
|
389
|
+
tracebacks_enabled=tracebacks_enabled,
|
|
390
390
|
summary_limit=summary_limit,
|
|
391
391
|
verbose_limit=verbose_limit,
|
|
392
392
|
),
|
|
@@ -410,7 +410,7 @@ def _run_cli_via_exit_tools(
|
|
|
410
410
|
help="Show full Python traceback on errors",
|
|
411
411
|
)
|
|
412
412
|
@click.pass_context
|
|
413
|
-
def cli(ctx: click.Context, traceback: bool) -> None:
|
|
413
|
+
def cli(ctx: click.Context, *, traceback: bool) -> None:
|
|
414
414
|
"""Root command storing global flags and syncing shared traceback state.
|
|
415
415
|
|
|
416
416
|
Why
|
|
@@ -441,7 +441,7 @@ def cli(ctx: click.Context, traceback: bool) -> None:
|
|
|
441
441
|
"""
|
|
442
442
|
|
|
443
443
|
_record_traceback_choice(ctx, enabled=traceback)
|
|
444
|
-
_announce_traceback_choice(traceback)
|
|
444
|
+
_announce_traceback_choice(enabled=traceback)
|
|
445
445
|
if _no_subcommand_requested(ctx):
|
|
446
446
|
if _traceback_option_requested(ctx):
|
|
447
447
|
cli_main()
|
|
@@ -579,10 +579,10 @@ def main(
|
|
|
579
579
|
verbose_limit=verbose_limit,
|
|
580
580
|
)
|
|
581
581
|
finally:
|
|
582
|
-
_restore_when_requested(previous_state, restore_traceback)
|
|
582
|
+
_restore_when_requested(previous_state, should_restore=restore_traceback)
|
|
583
583
|
|
|
584
584
|
|
|
585
|
-
def _restore_when_requested(state: TracebackState, should_restore: bool) -> None:
|
|
585
|
+
def _restore_when_requested(state: TracebackState, *, should_restore: bool) -> None:
|
|
586
586
|
"""Restore the prior traceback configuration when requested.
|
|
587
587
|
|
|
588
588
|
Why
|
|
@@ -16,6 +16,8 @@ from pydantic import BaseModel, ConfigDict, Field, model_validator
|
|
|
16
16
|
from . import sanitization
|
|
17
17
|
|
|
18
18
|
REQUEST_TIMEOUT_SECONDS = 30
|
|
19
|
+
#: GitHub API status code returned when the org endpoint has no matching organization.
|
|
20
|
+
HTTP_STATUS_NOT_FOUND = 404
|
|
19
21
|
|
|
20
22
|
logger = logging.getLogger(__name__)
|
|
21
23
|
|
|
@@ -66,7 +68,7 @@ class GitHubRepositoriesResponse(BaseModel):
|
|
|
66
68
|
|
|
67
69
|
@model_validator(mode="before")
|
|
68
70
|
@classmethod
|
|
69
|
-
def _wrap_list_response(cls, data: Any) -> dict[str, Any]:
|
|
71
|
+
def _wrap_list_response(cls, data: Any) -> dict[str, Any]:
|
|
70
72
|
"""Wrap list responses into the expected dict structure."""
|
|
71
73
|
if isinstance(data, list):
|
|
72
74
|
return {"repositories": data}
|
|
@@ -128,7 +130,7 @@ class GitHubErrorResponse(BaseModel):
|
|
|
128
130
|
message: str = "Error"
|
|
129
131
|
|
|
130
132
|
@classmethod
|
|
131
|
-
def from_response(cls, response: requests.Response | None) ->
|
|
133
|
+
def from_response(cls, response: requests.Response | None) -> GitHubErrorResponse:
|
|
132
134
|
"""Parse error from response, handling various failure modes."""
|
|
133
135
|
if response is None:
|
|
134
136
|
return cls()
|
|
@@ -148,7 +150,7 @@ class PaginationLink(BaseModel):
|
|
|
148
150
|
url: str = ""
|
|
149
151
|
|
|
150
152
|
@classmethod
|
|
151
|
-
def from_link_dict(cls, link_data: dict[str, str] | None) ->
|
|
153
|
+
def from_link_dict(cls, link_data: dict[str, str] | None) -> PaginationLink | None:
|
|
152
154
|
"""Parse pagination link from requests library link dict.
|
|
153
155
|
|
|
154
156
|
Parameters
|
|
@@ -367,12 +369,12 @@ def enable_all_workflows(owner: str, github_token: str) -> None:
|
|
|
367
369
|
Activating ...
|
|
368
370
|
|
|
369
371
|
"""
|
|
370
|
-
|
|
372
|
+
sys.stdout.write(f"Activating and maintaining all workflows for owner {owner}:\n")
|
|
371
373
|
repositories = get_repositories(owner=owner, github_token=github_token)
|
|
372
374
|
for repository in repositories:
|
|
373
375
|
workflows = get_workflows(owner=owner, repository=repository, github_token=github_token)
|
|
374
376
|
for workflow_filename in workflows:
|
|
375
|
-
|
|
377
|
+
sys.stdout.write(f"activate workflow {repository}/{workflow_filename}\n")
|
|
376
378
|
enable_workflow(owner=owner, repository=repository, workflow_filename=workflow_filename, github_token=github_token)
|
|
377
379
|
|
|
378
380
|
|
|
@@ -394,8 +396,9 @@ def delete_old_workflow_runs(owner: str, github_token: str, number_of_workflow_r
|
|
|
394
396
|
|
|
395
397
|
|
|
396
398
|
"""
|
|
397
|
-
|
|
398
|
-
f"Removing outdated workflow executions for owner {owner},
|
|
399
|
+
sys.stdout.write(
|
|
400
|
+
f"Removing outdated workflow executions for owner {owner}, "
|
|
401
|
+
f"while retaining a maximum of {number_of_workflow_runs_to_keep} workflow runs per repository:\n"
|
|
399
402
|
)
|
|
400
403
|
l_repositories = get_repositories(owner=owner, github_token=github_token)
|
|
401
404
|
for repository in l_repositories:
|
|
@@ -408,7 +411,7 @@ def delete_old_workflow_runs(owner: str, github_token: str, number_of_workflow_r
|
|
|
408
411
|
)
|
|
409
412
|
)
|
|
410
413
|
for run_id_to_delete in workflow_run_ids_to_delete:
|
|
411
|
-
|
|
414
|
+
sys.stdout.write(f"remove workflow run {repository}/{run_id_to_delete}\n")
|
|
412
415
|
delete_workflow_run(owner=owner, repository=repository, github_token=github_token, run_id_to_delete=run_id_to_delete)
|
|
413
416
|
|
|
414
417
|
|
|
@@ -501,7 +504,7 @@ def get_repositories(owner: str, github_token: str) -> list[str]:
|
|
|
501
504
|
org_url = f"https://api.github.com/orgs/{owner}/repos?per_page=100"
|
|
502
505
|
user_url = f"https://api.github.com/users/{owner}/repos?per_page=100"
|
|
503
506
|
probe = requests.get(org_url, headers=headers, timeout=REQUEST_TIMEOUT_SECONDS)
|
|
504
|
-
if probe.status_code ==
|
|
507
|
+
if probe.status_code == HTTP_STATUS_NOT_FOUND:
|
|
505
508
|
url: str | None = user_url
|
|
506
509
|
probe = None # Discard the 404 so the loop fetches fresh from user endpoint.
|
|
507
510
|
else:
|
|
@@ -730,4 +733,4 @@ def main() -> None:
|
|
|
730
733
|
|
|
731
734
|
|
|
732
735
|
if __name__ == "__main__":
|
|
733
|
-
|
|
736
|
+
sys.stderr.write("this is a library only, the executable is named 'keep_github_workflows_active_cli.py'\n")
|
|
@@ -8,10 +8,10 @@ functions returning sanitized copies without mutating inputs.
|
|
|
8
8
|
|
|
9
9
|
Contents
|
|
10
10
|
--------
|
|
11
|
-
* :func:`sanitize_headers`
|
|
12
|
-
* :func:`sanitize_message`
|
|
13
|
-
* :func:`sanitize_dict`
|
|
14
|
-
* :func:`sanitize_for_logging`
|
|
11
|
+
* :func:`sanitize_headers` - redact Authorization and authentication headers.
|
|
12
|
+
* :func:`sanitize_message` - redact token-like patterns from text.
|
|
13
|
+
* :func:`sanitize_dict` - recursively sanitize dictionary values.
|
|
14
|
+
* :func:`sanitize_for_logging` - convenience wrapper for common logging scenarios.
|
|
15
15
|
|
|
16
16
|
System Role
|
|
17
17
|
-----------
|
|
@@ -23,8 +23,9 @@ ensure credentials never leak into log files or monitoring systems.
|
|
|
23
23
|
from __future__ import annotations
|
|
24
24
|
|
|
25
25
|
import re
|
|
26
|
+
from collections.abc import Mapping
|
|
26
27
|
from collections.abc import Mapping as MappingABC
|
|
27
|
-
from typing import Any
|
|
28
|
+
from typing import Any
|
|
28
29
|
|
|
29
30
|
#: HTTP header names that contain sensitive authentication data.
|
|
30
31
|
SENSITIVE_HEADERS = frozenset(
|
|
@@ -64,11 +65,17 @@ SENSITIVE_KEYS = frozenset(
|
|
|
64
65
|
REDACTED_PLACEHOLDER = "[REDACTED]"
|
|
65
66
|
|
|
66
67
|
#: Pattern matching token-like strings:
|
|
67
|
-
#: - GitHub tokens (ghp_, gho_, ghs_, etc.
|
|
68
|
+
#: - GitHub tokens (ghp_, gho_, ghs_, etc.). Installation tokens (ghs_) are now long
|
|
69
|
+
#: JWT-format strings (~520 chars) that contain dots, dashes and underscores, so the
|
|
70
|
+
#: token body allows ".-_" and carries no trailing word boundary (a token may end in
|
|
71
|
+
#: "-", which is not a word char and would otherwise truncate the match and leak the
|
|
72
|
+
#: remainder of the JWT).
|
|
68
73
|
#: - Long hex strings (40+ chars)
|
|
69
74
|
#: - Base64-like sequences (40+ chars)
|
|
70
75
|
TOKEN_PATTERN = re.compile(
|
|
71
|
-
r"\
|
|
76
|
+
r"\bgh[a-z]_[A-Za-z0-9._-]{36,}"
|
|
77
|
+
r"|\b[a-f0-9]{40,}\b"
|
|
78
|
+
r"|\b[A-Za-z0-9+/]{40,}={0,2}\b",
|
|
72
79
|
re.IGNORECASE,
|
|
73
80
|
)
|
|
74
81
|
|
|
@@ -256,7 +263,7 @@ def _is_sensitive_key(name: str) -> bool:
|
|
|
256
263
|
return name.lower() in SENSITIVE_KEYS or name.lower() in SENSITIVE_HEADERS
|
|
257
264
|
|
|
258
265
|
|
|
259
|
-
def _sanitize_dict_value(key: str, value: Any) -> Any:
|
|
266
|
+
def _sanitize_dict_value(key: str, value: Any) -> Any:
|
|
260
267
|
"""Return sanitized value for dictionary entry.
|
|
261
268
|
|
|
262
269
|
Parameters
|
|
@@ -327,7 +334,7 @@ def sanitize_dict(data: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
327
334
|
return {key: _sanitize_dict_value(key, value) for key, value in data.items()}
|
|
328
335
|
|
|
329
336
|
|
|
330
|
-
def sanitize_for_logging(value: Any) -> Any:
|
|
337
|
+
def sanitize_for_logging(value: Any) -> Any:
|
|
331
338
|
"""Return sanitized representation suitable for logging.
|
|
332
339
|
|
|
333
340
|
Why
|
|
@@ -368,12 +375,12 @@ def sanitize_for_logging(value: Any) -> Any: # noqa: ANN401
|
|
|
368
375
|
|
|
369
376
|
|
|
370
377
|
__all__ = [
|
|
378
|
+
"REDACTED_PLACEHOLDER",
|
|
371
379
|
"SENSITIVE_HEADERS",
|
|
372
380
|
"SENSITIVE_KEYS",
|
|
373
|
-
"REDACTED_PLACEHOLDER",
|
|
374
381
|
"TOKEN_PATTERN",
|
|
375
|
-
"sanitize_headers",
|
|
376
|
-
"sanitize_message",
|
|
377
382
|
"sanitize_dict",
|
|
378
383
|
"sanitize_for_logging",
|
|
384
|
+
"sanitize_headers",
|
|
385
|
+
"sanitize_message",
|
|
379
386
|
]
|
|
@@ -1,32 +1,51 @@
|
|
|
1
|
-
"""Strictly-typed wrappers for rich_click
|
|
1
|
+
"""Strictly-typed wrappers for rich_click's partially-typed decorators.
|
|
2
2
|
|
|
3
|
-
rich_click ships ``py.typed
|
|
4
|
-
|
|
5
|
-
``reportUnknownMemberType`` at every call site.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
touches the untyped surface, so the only ``# pyright: ignore`` for this gap lives here.
|
|
3
|
+
rich_click ships ``py.typed``, but its ``option`` and ``version_option``
|
|
4
|
+
decorators are typed with a partially-unknown return, so the strict type checker
|
|
5
|
+
reports ``reportUnknownMemberType`` at every call site. click's own decorators
|
|
6
|
+
are fully typed, but they default the parameter class to ``click.Option`` rather
|
|
7
|
+
than rich_click's ``RichOption``, which would change help rendering.
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
still used
|
|
9
|
+
This module forwards to rich_click's decorators (so ``RichOption``/``RichArgument``
|
|
10
|
+
are still used at runtime) through a typed ``Protocol``: the ``cast`` is a no-op
|
|
11
|
+
at runtime, and the wrappers keep the exact same public signatures they always
|
|
12
|
+
had, so no rule needs to be silenced anywhere.
|
|
13
|
+
|
|
14
|
+
Other click members (``command``, ``group``, ``echo``, ``Context``, ``Path`` ...)
|
|
15
|
+
type cleanly and are still used directly as ``click.X`` at call sites.
|
|
12
16
|
"""
|
|
13
17
|
|
|
14
18
|
from collections.abc import Callable
|
|
15
|
-
from typing import Any
|
|
19
|
+
from typing import Any, Protocol, cast
|
|
16
20
|
|
|
17
21
|
import rich_click as click
|
|
18
22
|
|
|
23
|
+
# Click decorators turn a command function (or another decorator's result) into a
|
|
24
|
+
# wrapped callable. ``Any`` is fully known to the type checker, so this alias stays
|
|
25
|
+
# clean and works both as ``@option(...)`` and as a value collected into a list.
|
|
19
26
|
_CommandDecorator = Callable[[Callable[..., Any]], Callable[..., Any]]
|
|
20
27
|
|
|
21
28
|
|
|
29
|
+
class _RichClickDecorators(Protocol):
|
|
30
|
+
"""rich_click's decorator surface, declared with complete types."""
|
|
31
|
+
|
|
32
|
+
option: Callable[..., _CommandDecorator]
|
|
33
|
+
version_option: Callable[..., _CommandDecorator]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# ``cast`` is type-only; at runtime these forward to rich_click's own decorators,
|
|
37
|
+
# so ``RichOption``/``RichArgument`` behavior is unchanged.
|
|
38
|
+
_click = cast("_RichClickDecorators", click)
|
|
39
|
+
|
|
40
|
+
|
|
22
41
|
def option(*param_decls: str, **attrs: Any) -> _CommandDecorator:
|
|
23
42
|
"""Typed wrapper over :func:`rich_click.option`. See module docstring."""
|
|
24
|
-
return
|
|
43
|
+
return _click.option(*param_decls, **attrs)
|
|
25
44
|
|
|
26
45
|
|
|
27
46
|
def version_option(*param_decls: str, **attrs: Any) -> _CommandDecorator:
|
|
28
47
|
"""Typed wrapper over :func:`rich_click.version_option`. See module docstring."""
|
|
29
|
-
return
|
|
48
|
+
return _click.version_option(*param_decls, **attrs)
|
|
30
49
|
|
|
31
50
|
|
|
32
51
|
__all__ = ["option", "version_option"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: keep_github_workflows_active
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.3
|
|
4
4
|
Summary: Template for python apps with registered cli commands
|
|
5
5
|
Project-URL: Homepage, https://github.com/bitranox/keep_github_workflows_active
|
|
6
6
|
Project-URL: Repository, https://github.com/bitranox/keep_github_workflows_active.git
|
|
@@ -17,22 +17,22 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.14
|
|
18
18
|
Classifier: Typing :: Typed
|
|
19
19
|
Requires-Python: >=3.10
|
|
20
|
-
Requires-Dist: lib-cli-exit-tools>=2.3.
|
|
20
|
+
Requires-Dist: lib-cli-exit-tools>=2.3.3
|
|
21
21
|
Requires-Dist: pydantic>=2.13.4
|
|
22
22
|
Requires-Dist: requests>=2.34.2
|
|
23
23
|
Requires-Dist: rich-click>=1.9.8
|
|
24
24
|
Provides-Extra: dev
|
|
25
25
|
Requires-Dist: bandit>=1.9.4; extra == 'dev'
|
|
26
26
|
Requires-Dist: build>=1.5.0; extra == 'dev'
|
|
27
|
-
Requires-Dist:
|
|
28
|
-
Requires-Dist: import-linter>=2.
|
|
27
|
+
Requires-Dist: click>=8.4.2; extra == 'dev'
|
|
28
|
+
Requires-Dist: import-linter>=2.13; extra == 'dev'
|
|
29
29
|
Requires-Dist: pip-audit>=2.10.1; extra == 'dev'
|
|
30
|
-
Requires-Dist: pyright[nodejs]>=1.1.
|
|
30
|
+
Requires-Dist: pyright[nodejs]>=1.1.411; extra == 'dev'
|
|
31
31
|
Requires-Dist: pytest-cov>=7.1.0; extra == 'dev'
|
|
32
|
-
Requires-Dist: pytest>=9.1.
|
|
32
|
+
Requires-Dist: pytest>=9.1.1; extra == 'dev'
|
|
33
33
|
Requires-Dist: rtoml>=0.13.0; extra == 'dev'
|
|
34
|
-
Requires-Dist: ruff>=0.
|
|
35
|
-
Requires-Dist: textual>=8.2.
|
|
34
|
+
Requires-Dist: ruff>=0.16.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: textual>=8.2.8; extra == 'dev'
|
|
36
36
|
Requires-Dist: twine>=6.2.0; extra == 'dev'
|
|
37
37
|
Description-Content-Type: text/markdown
|
|
38
38
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
keep_github_workflows_active/__init__.py,sha256=AlRr46bcAznN5xCoFiwEyc65m6kbfGBB5l30iIzq-Q4,399
|
|
2
|
+
keep_github_workflows_active/__init__conf__.py,sha256=gc2KCQa4E7lVt5AtR-YDFJox54lFyEI9WVgIqdUYNxk,2592
|
|
3
|
+
keep_github_workflows_active/__main__.py,sha256=tFOQl70Tnf47fz4ylnN3p0dSjoLeHdLMe9dh-ISfpgE,3589
|
|
4
|
+
keep_github_workflows_active/behaviors.py,sha256=6ck9W-QIwHox6j93XHFL57f_YRwgDkxooa6FtxmnPdw,3733
|
|
5
|
+
keep_github_workflows_active/cli.py,sha256=eqeMrqBltwHvmNPyz8i5az5_0dVPnJbb4Mloa4vmZn0,19070
|
|
6
|
+
keep_github_workflows_active/doctest.env,sha256=WmDSq0QN1PFXpP4jq7JW_Kz-k5PT5uS8KzLrAEmJNC8,25
|
|
7
|
+
keep_github_workflows_active/keep_github_workflow_active.py,sha256=c8FfZuYmwv27eG6D2gGauX-oLiYsx61cCGabal-6UJM,25952
|
|
8
|
+
keep_github_workflows_active/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
keep_github_workflows_active/sanitization.py,sha256=cuG2Lbn0Ca4h6NP2f7Z2rSwio_3c_wy3dNsofUwaGOc,10115
|
|
10
|
+
keep_github_workflows_active/typed_click.py,sha256=VLZgUkCZ6AFnf6StvoztK3JVYj9lZmgPSNY2Wjb3B8g,2183
|
|
11
|
+
keep_github_workflows_active-2.3.3.dist-info/METADATA,sha256=33zyXo8k5AVzUX7Sx85tBVoRULpOIxpxWlJ116JiCWE,9405
|
|
12
|
+
keep_github_workflows_active-2.3.3.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
13
|
+
keep_github_workflows_active-2.3.3.dist-info/entry_points.txt,sha256=6B8ytwKR2VIAj6IXUYhF957dlfulwTPPLR39RBXwCM0,156
|
|
14
|
+
keep_github_workflows_active-2.3.3.dist-info/licenses/LICENSE,sha256=6s9SL2InRrwynPjJYiER7ONHBshbGj_yC5EBzfo7l9I,1072
|
|
15
|
+
keep_github_workflows_active-2.3.3.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
keep_github_workflows_active/__init__.py,sha256=tAEJPhRW07E84IzHijcwAf-iu8fhAf3TsvBUQqGz-fY,399
|
|
2
|
-
keep_github_workflows_active/__init__conf__.py,sha256=UFtHXaX8-YSHnd1vjmjAwo8lXbwMzt2Lp1N6t4eA2zg,2562
|
|
3
|
-
keep_github_workflows_active/__main__.py,sha256=79coRxvGs07uGBSdbw_HpcIv_rqogXvoEkv3lNEEIjE,3552
|
|
4
|
-
keep_github_workflows_active/behaviors.py,sha256=PYDhp_ubXhLud2IVFLIJKylStu36W4Qm7E_daT2dOAM,3741
|
|
5
|
-
keep_github_workflows_active/cli.py,sha256=5JvgQSG7vdCD33WB31hLCWaeOjcFmFzSIeECCKBipeE,19013
|
|
6
|
-
keep_github_workflows_active/doctest.env,sha256=WmDSq0QN1PFXpP4jq7JW_Kz-k5PT5uS8KzLrAEmJNC8,25
|
|
7
|
-
keep_github_workflows_active/keep_github_workflow_active.py,sha256=Ri4xOS-Cbg1qO2EasRzlvV59Du0WBruiCnpntVN8cBI,25779
|
|
8
|
-
keep_github_workflows_active/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
keep_github_workflows_active/sanitization.py,sha256=zyPybyYLBWd__nITF8nyrubA3NJWXjyGkznw-4kJtyA,9801
|
|
10
|
-
keep_github_workflows_active/typed_click.py,sha256=IT7GkOwnlq4ZlnGEKHl-nqkzN0Fd6YqjWOBdYFH96uU,1380
|
|
11
|
-
keep_github_workflows_active-2.3.2.dist-info/METADATA,sha256=Xda34BPNWHukVnVvRTj9zWqnbnEo39P-NPTMZPQjWBs,9413
|
|
12
|
-
keep_github_workflows_active-2.3.2.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
13
|
-
keep_github_workflows_active-2.3.2.dist-info/entry_points.txt,sha256=6B8ytwKR2VIAj6IXUYhF957dlfulwTPPLR39RBXwCM0,156
|
|
14
|
-
keep_github_workflows_active-2.3.2.dist-info/licenses/LICENSE,sha256=6s9SL2InRrwynPjJYiER7ONHBshbGj_yC5EBzfo7l9I,1072
|
|
15
|
-
keep_github_workflows_active-2.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|