settings

Configuration for the redeemer.

Settings resolve from, in order of precedence: explicit arguments, environment variables prefixed HSKR_, a .env file, then the defaults below.

State is kept under a single application directory rather than scattered through the working directory, so running the tool from a different folder does not silently start from an empty history.

class humble_steam_key_redeemer.settings.Settings(_case_sensitive=None, _nested_model_default_partial_update=None, _env_prefix=None, _env_prefix_target=None, _env_file=PosixPath('.'), _env_file_encoding=None, _env_ignore_empty=None, _env_nested_delimiter=None, _env_nested_max_split=None, _env_parse_none_str=None, _env_parse_enums=None, _cli_prog_name=None, _cli_parse_args=None, _cli_settings_source=None, _cli_parse_none_str=None, _cli_hide_none_type=None, _cli_avoid_json=None, _cli_enforce_required=None, _cli_use_class_docs_for_groups=None, _cli_show_env_vars=None, _cli_exit_on_error=None, _cli_prefix=None, _cli_flag_prefix_char=None, _cli_implicit_flags=None, _cli_ignore_unknown_args=None, _cli_kebab_case=None, _cli_shortcuts=None, _secrets_dir=None, _build_sources=None, **values)[source]

Bases: BaseSettings

Runtime configuration.

Variables:
  • state_dir – Directory holding the database and saved sessions.

  • match_threshold – Similarity score above which a Humble title is considered to match an owned Steam app.

  • confirm_threshold – Score at or above which a match is trusted without asking the user.

  • cdp_endpoint – Attach to an existing browser at this CDP endpoint (for example http://localhost:9222) rather than launching one.

  • headless – Whether the Humble browser runs without a visible window.

  • browser_timeout_ms – Per-operation browser timeout in milliseconds.

  • request_timeout – HTTP timeout in seconds.

  • locale – Browser locale, which determines Humble’s currency display.

Parameters:
  • _case_sensitive (bool | None)

  • _nested_model_default_partial_update (bool | None)

  • _env_prefix (str | None)

  • _env_prefix_target (EnvPrefixTarget | None)

  • _env_file (DotenvType | None)

  • _env_file_encoding (str | None)

  • _env_ignore_empty (bool | None)

  • _env_nested_delimiter (str | None)

  • _env_nested_max_split (int | None)

  • _env_parse_none_str (str | None)

  • _env_parse_enums (bool | None)

  • _cli_prog_name (str | None)

  • _cli_parse_args (bool | list[str] | tuple[str, ...] | None)

  • _cli_settings_source (CliSettingsSource[Any] | None)

  • _cli_parse_none_str (str | None)

  • _cli_hide_none_type (bool | None)

  • _cli_avoid_json (bool | None)

  • _cli_enforce_required (bool | None)

  • _cli_use_class_docs_for_groups (bool | None)

  • _cli_show_env_vars (bool | None)

  • _cli_exit_on_error (bool | None)

  • _cli_prefix (str | None)

  • _cli_flag_prefix_char (str | None)

  • _cli_implicit_flags (bool | Literal['dual', 'toggle'] | None)

  • _cli_ignore_unknown_args (bool | None)

  • _cli_kebab_case (bool | Literal['all', 'no_enums'] | None)

  • _cli_shortcuts (Mapping[str, str | list[str]] | None)

  • _secrets_dir (PathType | None)

  • _build_sources (tuple[tuple[PydanticBaseSettingsSource, ...], dict[str, Any]] | None)

  • state_dir (Path)

  • match_threshold (Annotated[int, Ge(ge=0), Le(le=100)])

  • confirm_threshold (Annotated[int, Ge(ge=0), Le(le=100)])

  • cdp_endpoint (str | None)

  • headless (bool)

  • browser (Literal['chromium', 'firefox', 'webkit'])

  • browser_timeout_ms (Annotated[int, Gt(gt=0)])

  • request_timeout (Annotated[float, Gt(gt=0)])

  • locale (str)

  • max_redemptions_per_run (Annotated[int, Ge(ge=0)])

model_config = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'cli_avoid_json': False, 'cli_enforce_required': False, 'cli_exit_on_error': True, 'cli_flag_prefix_char': '-', 'cli_hide_none_type': False, 'cli_ignore_unknown_args': False, 'cli_implicit_flags': False, 'cli_kebab_case': False, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_prefix': '', 'cli_prog_name': None, 'cli_shortcuts': None, 'cli_show_env_vars': False, 'cli_use_class_docs_for_groups': False, 'enable_decoding': True, 'env_file': '.env', 'env_file_encoding': 'utf-8', 'env_ignore_empty': False, 'env_nested_delimiter': None, 'env_nested_max_split': None, 'env_parse_enums': None, 'env_parse_none_str': None, 'env_prefix': 'HSKR_', 'env_prefix_target': 'variable', 'extra': 'ignore', 'json_file': None, 'json_file_encoding': None, 'nested_model_default_partial_update': False, 'protected_namespaces': ('model_validate', 'model_dump', 'settings_customise_sources'), 'secrets_dir': None, 'toml_file': None, 'validate_default': True, 'yaml_config_section': None, 'yaml_file': None, 'yaml_file_encoding': None}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

state_dir: Path
match_threshold: int
confirm_threshold: int
cdp_endpoint: str | None
headless: bool
browser: Literal['chromium', 'firefox', 'webkit']
browser_timeout_ms: int
request_timeout: float
locale: str
max_redemptions_per_run: int
property database_path: Path

Path to the SQLite database of keys and redemption attempts.

property humble_session_path: Path

Path to the stored Humble browser session.

property steam_session_path: Path

Path to the stored Steam session.

ensure_state_dir()[source]

Create the state directory with owner-only permissions.

Session files here are bearer credentials — a copied Steam session bypasses Steam Guard — so the directory must not be group- or world-accessible.

mkdir(mode=...) only applies to a directory it actually creates and is further masked by the umask, so the mode is set explicitly afterwards. Otherwise a directory that already existed with loose permissions would silently keep them.

Return type:

Path

Returns:

The state directory path.