Add pre-commit setup and remove unused six dependency - #32
Merged
Conversation
Mirrors the org's modern pre-commit reference (eng-guidance-mcp) per DRAFT-032: universal hooks + yamllint/yamlfmt/mdformat + isort/black/ mypy/pylint, plus a Pre-commit GitHub Actions workflow that enforces the hooks in CI on every PR. Production-code edits are limited to behavior-preserving cleanups so the CLI invocation surface stays byte-identical: - Drop the unused `six` dependency from requirements.txt, setup.py, and oktaawscli/aws_auth.py. - Refactor setup.py to parse `__version__` via regex instead of `exec(open(...).read())` (mypy-clean and avoids the implicit eval). - Simplify `role_choice >= 0 and role_choice < len(role_info)` to `0 <= role_choice < len(role_info)` in aws_auth.py. - Drop an unused `as ex` binding from a `except ClientError:` in aws_auth.py. - Add `# type: ignore[name-defined] # noqa: F821` to the py2 `raw_input` compat shim in okta_auth_config.py. - Remove inline `# pylint: disable=...` headers from the three module files in oktaawscli/; rules are now centralized in the new pylintrc. The E1120 disable/enable pair around click's `main()` invocation is preserved. mypy.ini and pylintrc are deliberately permissive for this legacy codebase (Python 2 compat shims, % string formatting, mixed exit()/ sys.exit()). All other diffs are pure auto-formatting from black, isort, yamlfmt, and mdformat. Verified: `pre-commit run --all-files` is clean and `tox` runs all 23 existing tests green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- setup.py: import __version__ directly from oktaawscli.version instead of regex-parsing the source file. oktaawscli/__init__.py only imports from .version (no runtime deps), so the import is safe in setup.py before deps are installed. - aws_auth.py / okta_auth.py: collapse five awkward multi-line log strings that leaked embedded indentation into user-visible output. The runtime strings now read as single clean sentences instead of carrying newlines + dozens of spaces between clauses. Log content is otherwise unchanged. - Workflows: fold the separate pre-commit.yml into pr_check.yml so PRs see a single check job. The consolidated job does the DRAFT-032 base-branch merge, runs pre-commit/action, then runs tox — matching what the two split workflows did, but with one status check. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Bump __version__ and add a CHANGELOG entry covering the pre-commit setup and the safe production-code cleanups (drop six, setup.py refactor, log string normalization) that landed on this branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jconstance-amplify
marked this pull request as ready for review
May 16, 2026 19:23
aoskotsky-amplify
approved these changes
May 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a proper pre-commit configuration mirroring the org's modern reference (
eng-guidance-mcp) per DRAFT-032: Pre-commit Standards, plus a GitHub Actions workflow that enforces the hooks in CI. Removes the unusedsixdependency. All other production-code edits are behavior-preserving cleanups — the CLI invocation surface is byte-identical.Why
The repo had no pre-commit setup, so style/lint issues only surface in code review (or not at all). Adopting the standard hooks gives us:
pre-commit/action@v3.0.1with base-branch merge per DRAFT-032).detect-private-key,detect-aws-credentials,check-added-large-files.^oktaawscli/) + pylint, with a permissive but documentedpylintrcfor the legacy patterns this codebase already uses.What's in the box
Pre-commit configuration
.pre-commit-config.yaml,.yamllint.yml,mypy.ini,pylintrc— adapted from theeng-guidance-mcpreference..github/workflows/pre-commit.yml— runspre-commit/action@v3.0.1on every PR with--all-files --show-diff-on-failure. Usesubuntu-latest(this repo is public; org self-hosted runners are disabled for public repos) and Python 3.11 (matchespr_check.yml).Behavior-preserving cleanups
siximport + dependency (requirements.txt,setup.py,oktaawscli/aws_auth.py).setup.pyto parse__version__via regex instead ofexec(open(...).read())— mypy-clean and avoids implicit eval.role_choice >= 0 and role_choice < len(role_info)→0 <= role_choice < len(role_info)inaws_auth.py.as exbinding fromexcept ClientError:inaws_auth.py:303.# type: ignore[name-defined] # noqa: F821to the py2raw_inputcompat shim inokta_auth_config.py:10.# pylint: disable=...headers from the threeoktaawscli/modules; rules centralized inpylintrc. TheE1120disable/enable pair around click'smain()invocation is preserved.All other diffs are pure auto-formatting from black/isort/yamlfmt/mdformat.
Why these specific hooks
The
pylintrcdisable list is broad — the codebase has Python 2/3 compat shims (input = input,input = raw_input),%-formatted log strings, mixedexit()vssys.exit(), and no type annotations. Each disable has a rationale comment. The intent is a permissive baseline for this legacy code so new contributions get caught without forcing a refactoring pass on existing code.Test plan
Pre-commitworkflow (new) runs cleanly against the merge result.PR checkworkflow (existing) runs the 23-test unittest suite under tox.okta-awscli --okta-profile Xworks unchanged.pip install .installs cleanly and reports the expected version (0.4.14).python -O setup.py --versionreports 0.4.14 (no AssertionError if the regex stripped out).Related
amplify-education/eng-guidance-mcp/.pre-commit-config.yaml🤖 Generated with Claude Code