Skip to content

Update for Python3#4

Open
sam-fakhreddine wants to merge 29 commits intosymonsoft:masterfrom
sam-fakhreddine:master
Open

Update for Python3#4
sam-fakhreddine wants to merge 29 commits intosymonsoft:masterfrom
sam-fakhreddine:master

Conversation

@sam-fakhreddine
Copy link
Copy Markdown

No description provided.

sam-fakhreddine and others added 29 commits October 17, 2023 13:47
Robustness fixes in str_utils.py:
- Strip leading/trailing whitespace from string inputs
- Accept bool inputs directly (pass-through True/False)
- Accept int inputs: 1→True, 0→False; other ints are invalid
- Raise TypeError for unsupported types (float, list, etc.)
- Fix str2bool_exc(None): now raises ValueError instead of silently
  returning None, consistent with the function's contract

Testing:
- Add tests/test_str_utils.py with 76 tests covering all inputs,
  edge cases, error messages, and both str2bool / str2bool_exc

Packaging:
- Add pyproject.toml (PEP 517/518); keep setup.py for CI version
  injection from git tags
- Update README: correct import examples, document new behaviour,
  add API reference table

CI/CD:
- Add matrix test job across Python 3.8–3.12 before build/publish
- Gate build on tests passing; gate publish on build
- Bump actions/checkout, setup-python, upload/download-artifact to
  latest versions (v4/v5)
- Trigger tests on push to master and all pull requests, not just tags

https://claude.ai/code/session_017rKszX11QmRRdhMhBf9vCu
Replaced non-existent 'setuptools.backends.legacy:build' with the
correct 'setuptools.build_meta' backend. Also moved version to
dynamic (provided by setup.py) to avoid duplicate-version conflict
between pyproject.toml and setup.py.

https://claude.ai/code/session_017rKszX11QmRRdhMhBf9vCu
Value sets:
- Add 'on'/'off' and 'enabled'/'disabled' to TRUE_VALUES/FALSE_VALUES
- Rename TRUE_SET/FALSE_SET → TRUE_VALUES/FALSE_VALUES (public, frozenset)
- Export TRUE_VALUES and FALSE_VALUES via __init__.__all__

Refactor:
- Extract _parse() — single place for all type-dispatch logic; both
  str2bool() and any future callers share it without duplication
- Pre-compute _VALID string once at import time (was rebuilt on every
  raise_exc call)
- _MISSING sentinel object cleanly separates 'unrecognized' from
  False/None return values
- _Input type alias removes the repeated Optional[Union[str,bool,int]]

Tests: 105 tests (up from 76), covering new values, public constants,
frozenset immutability, and disjoint-set invariant

https://claude.ai/code/session_017rKszX11QmRRdhMhBf9vCu
setup.py / pyproject.toml — single version source of truth:
- setup.py now always passes a version to setup() with a fallback
  default, eliminating the ambiguous no-version code path when
  PACKAGE_VERSION is unset (fixes the dual-declaration conflict noted
  in review)
- Add Python 3.13 / 3.14 classifiers to pyproject.toml

CI (workflows.yml):
- Extend test matrix to include Python 3.13 and 3.14

Tests (109, up from 105):
- test_none_raises_value_error: add match="Cannot convert None to bool"
  to lock in the user-facing error message
- Add four whitespace-only input tests ('   ', '\t\n') covering the
  default return, custom default, and raise_exc paths

https://claude.ai/code/session_017rKszX11QmRRdhMhBf9vCu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants