question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for running pyanalyze as a Pre-Commit hook

See original GitHub issue

As I’m sure you’re aware, Pre-Commit is a popular Python/cross-language hooks framework for managing variety of checking, linting, formatting and other tools automatically, on demand in in CIs. Adding a minimal .pre-commit-hooks.yaml file in the root of the repo with a few lines of config will allow other projects to easily adopt pyanalyze, either locally or on CI, by simply pasting a couple-line snippet into their .pre-commit-config.yaml file, and pre-commit will install, run and update pyanalyze automagically, making it much easier to adopt, configure and maintain.

I’d be happy to add this in a PR if you don’t object; I’d also document it with the standard snippit in the README. Once this goes in (as well as PR #215 ), it would be nice to have a release sometime soon so we can start taking advantage of it. Thanks!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
JelleZijlstracommented, Jul 27, 2021

Thanks for looking into this! Yes, pyanalyze relies on actually importing the code it checks. Some sys.path hackery may make the pre-commit hook work, but I haven’t tried myself. One of the items on my to-do list is to make it easier to run pyanalyze on arbitrary projects without too much sys.path hackery.

1reaction
JelleZijlstracommented, Jul 27, 2021

The next one should be 0.3.0. I imagine I’m going to just go with 0.x.0 for a while.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Supported hooks - pre-commit
check-added-large-files - prevents giant files from being committed. check-ast - simply checks whether the files parse as valid python. check-byte-order-marker ...
Read more >
How to use git pre-commit hooks, the hard way and the easy ...
This hook runs when you run the command git commit . ... It means you can automatically run linters to statically analyze your...
Read more >
Pre-commit hooks you must know - Towards Data Science
pre -commit hooks are a mechanism of the version control system git. They let you execute code right before the commit.
Read more >
Using Precommit Hooks For Static Code Analysis
In this article we'll discuss how to use Git's pre-commit hooks to run our static code analysis tools on just the set of...
Read more >
Easier Code Review With Pre-Commit Hooks - Aryaman Sharda
Git hooks are scripts that run automatically every time a particular event occurs in a Git repository. They let you customize Git's internal ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found