Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-commit hook causes unexpected problems on existing codebase #143

Open
theferrit32 opened this issue Apr 9, 2024 · 1 comment
Open

Comments

@theferrit32
Copy link
Contributor

theferrit32 commented Apr 9, 2024

Describe the bug
When I take existing code in main and run the pre-commit checks installed by make devready, it fails, which means contributors cannot commit code to many existing files without disabling the pre-commit hook or fixing things unrelated to their change.

To Reproduce

Add a trivial edit to an existing git-tracked file which should be committable and not cause lint failures.

$ git clone  git@github.com:biocommons/biocommons.seqrepo.git biocommons.seqrepo-clean
$ cd biocommons.seqrepo-clean
$ make devready
$ source venv/bin/activate
$ echo "# blah" >> src/biocommons/seqrepo/cli.py
$ git add ./src/biocommons/seqrepo/cli.py
$ git commit -m "throwaway"

This fails on main.

Actual behavior

(venv) ➜  biocommons.seqrepo-clean git:(main) ✗ echo "# blah" >> src/biocommons/seqrepo/cli.py
(venv) ➜  biocommons.seqrepo-clean git:(main) ✗ git add ./src/biocommons/seqrepo/cli.py
(venv) ➜  biocommons.seqrepo-clean git:(main) ✗ git commit -m "throwaway"
flake8...................................................................Passed
pyright..................................................................Failed
- hook id: pyright
- exit code: 1

/Users/kferrite/dev/biocommons.seqrepo-clean/src/biocommons/seqrepo/cli.py
  /Users/kferrite/dev/biocommons.seqrepo-clean/src/biocommons/seqrepo/cli.py:331:37 - error: "execute" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/kferrite/dev/biocommons.seqrepo-clean/src/biocommons/seqrepo/cli.py:399:13 - error: Function declaration "_rec_iterator" is obscured by a declaration of the same name (reportRedeclaration)
  /Users/kferrite/dev/biocommons.seqrepo-clean/src/biocommons/seqrepo/cli.py:411:13 - error: Function declaration "_rec_iterator" is obscured by a declaration of the same name (reportRedeclaration)
  /Users/kferrite/dev/biocommons.seqrepo-clean/src/biocommons/seqrepo/cli.py:466:24 - error: Cannot access member "fetchone" for type "Generator[dict[Any, Any] | Unknown, Any, None]"
    Member "fetchone" is unknown (reportAttributeAccessIssue)
  /Users/kferrite/dev/biocommons.seqrepo-clean/src/biocommons/seqrepo/cli.py:697:53 - error: Cannot access member "seqinfo" for type "SeqRepo"
    Member "seqinfo" is unknown (reportAttributeAccessIssue)
5 errors, 0 warnings, 0 informations

isort....................................................................Passed
black....................................................................Passed
(venv) ➜  biocommons.seqrepo-clean git:(main) ✗  echo $?
1

Expected behavior
The git commit should succeed with exit code 0.

@jsstevenson
Copy link
Contributor

jsstevenson commented Apr 21, 2024

Fwiw there's also a pre commit command that will run hooks against every file regardless of staging status: I think it's --all?

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

No branches or pull requests

2 participants