-
Notifications
You must be signed in to change notification settings - Fork 19
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
Create style_docstr.yml #221
Conversation
Codecov Report
@@ Coverage Diff @@
## main #221 +/- ##
=======================================
Coverage 97.22% 97.22%
=======================================
Files 8 8
Lines 648 648
Branches 81 81
=======================================
Hits 630 630
Partials 18 18 |
@adam-grant-hendry Can you guess why mypy and pylint is not installed in https://github.com/pyvista/pyvistaqt/runs/7636558143?check_suite_focus=true ? |
@tkoyama010 Yes, I believe I see the problem. Our .pre-commit-config.yaml is using
Also, we should specify Detailed ExplanationTypically, a repo url is passed to
However, since the above runs in an isolated environment, it does not have access to your locally installed dependencies and locally installed configuration files. Some hooks have special environment requirements that don't allow them to be run in isolation. Two that are known are Note that for local hooks, all the following properties must be specified for the hook to run:
In addition, by default,
In the above cases, this may cause a fork bomb. See In these cases, it is recommended to
If they have The FixTo fix this, I would change the - repo: local
hooks:
- id: pylint
name: (pylint) Check for code smells
entry: pylint
language: system
types: [python]
require_serial: true
args: [
"-rn", # Only display messages
"-sn", # Don't display the score
]
- id: pytest
name: (pytest, coverage) Run tests and coverage
stages: [push]
entry: coverage run -m pytest && coverage html
types: [python]
language: system
pass_filenames: false
always_run: true
require_serial: true
- id: mypy
name: (mypy) Check static type hinting
entry: mypy
language: system
pass_filenames: false
types: [python]
require_serial: true NOTE: By default, these packages indicate they automatically search for and find configuration information in expected files: i.e. We also need to add a section to our CI to pip install AddendumI keep this at the top of my Precommit Instructions# By default, `pre-commit` only runs against changed files (i.e. files that have been
# modified and added to your `git` staging area with `git add`). Unstaged files will not
# be checked and `pre-commit` will not run if you have unstaged changes to your
# `.pre-commit-config.yaml`.
#
# So, when you first add a new hook to this repo, it is a good idea to save a local backup
# of your files on your branch
#
# git stash push -m 'WIP on your-branch'
#
# and then run the hook against all files in the repo
#
# pre-commit run your-new-hook --all-files
#
# This will show you how it works by default so you can add arguments to the hook or
# configure it to work exactly how you want. To restore your backup, run
#
# git reset --hard HEAD
# git stash apply
#
# Once you're sure you back to where you started, you can clear the stash
#
# git stash clear
#
# Individual hooks can be run by specifying their `id` to `pre-commit run`. All hooks in
# your `.pre-commit-config.yaml` can be run with `pre-commit run --all`.
#
# We often want to run against the latest version of the linter/formatters available. We
# also want to make sure all our hook configuration options are respected so we know it
# runs the way we expect across all systems (virtual environments, CI, different OS's,
# etc.)
#
# In general, you pass the hook repo url to `repo` and `pre-commit` creates an isolated
# (virtual) environment where it clones (downloads) necessary files and installs them.
# This is nice so that
# - you don't have to require developers to install the dependency (`pip install x` for
# Python)
# - the testing is independent of your system, which reduces gotcha's like "it works on
# my machine, but not yours" (forces you to be deliberate about passing configuration
# arguments to the hook)
#
# Because `pre-commit` runs in an isolated environment, it won't have access to your
# locally-installed dependencies. Hence, if the hook requires additional dependencies
# (like `toml`), you must specify them as additional dependencies to the hook:
#
# repo: https://yourhook.com
# rev: x.y.z
# hooks:
# - id: do-the-thing
# additiona_dependencies: [
# "toml"
# ]
#
# However, some hooks have special environment requirements that don't allow them to be
# run in isolation (e.g. `pylint` and `pytest`). For these, you pass the argument
# `'local'` to `repo` without a `rev` to specify that it will be run on the current
# machine (local or CI). `pre-commit` will not run these in an isolated virtual
# environment, so you must setup the virtual environment and install dependencies
# manually (typically from a maintained `requirements.txt` or `pyproject.toml` file).
#
# In addition, sometimes there are conflicts between the files `pre-commit` passes to
# your hook (the changed files in your staging area) and the hook that can't be well-
# managed with include or exclude configuration options. Other times, you may simply
# want to always to run a hook against the same set of files before commit (not just
# changed files in your staging area). For this, you can use
#
# `pass_filenames: false`
#
# Note that, in general, you want to avoid this because the hook will take longer to
# run (since you're always running against a fixed set of files in this case rather than
# just changed files). Alternatively, it is better to specify files to include and
# exclude:
#
# `files: ...`
# `exclude: ...`
#
# To ensure hooks stay up to date:
#
# 1. For non-local hooks (using the repo url), run
#
# pre-commit autoupdate --repo hook-repo-url
#
# To update all hooks in your `.pre-commit-config.yaml` automatically, run
#
# pre-commit autoupdate
#
# (NOTE: You usually ALWAYS want `rev`` hard-coded to a specific release tag and let
# `autoupdate` handle updating the hook version. This way, you know exactly which
# version of the hook is running. Also, `pre-commit` typically warns about "floating"
# or imprecise revs) To update to the latest rev, use.
#
# 2. For local hooks, dependencies must be updated manually (e.g. `pip install --upgrade`)
#
# Note that for local hooks, all the following properties must be specified for the hook
# to run:
#
# - id
# - name
# - language
# - entry
# - files/types
#
# Finally, By default, `pre-commit` runs all hooks sequentially in the order they are
# listed in the `.pre-commit-config.yaml`. However, since version `v1.13.0`, `pre-commit`
# runs each _individual hook operation_ on all the files passed to it in parallel. The is
# beneficial for the majority of cases since it means each hook will execute faster, but
# there are some scenarios where this may present a problem:
#
# - if a hook reads from other files not passed to it (e.g. a configuration file), or
# - if a hook writes to other files not passed to it (e.g. a log file)
#
# In the above cases, this may create a fork bomb. See
#
# - https://github.com/pre-commit/pre-commit/issues/510
#
# In the event your hook needs to access the same file across multiple processes, you can
# specify the hook be run on files sequentially by passing
#
# - `require_serial: true`
#
# In general, when using a third-party package locally, it is recommended to go to the
# package repo, look at their `.pre-commit-config.yaml` and/or `.pre-commit-hooks.yaml`
# and see if they have specified `require_serial: true`. If yes, it should be added as
# a parameter. However, if not specified, it is good to add it anyway as a precaution
# (or in the event you encounter problems when using the package).
# |
Co-authored-by: adam-grant-hendry <[email protected]>
@adam-grant-hendry Thank you very much. I don't quite understand, but there is no CI installation of mypy and pylint in the pyvista/pyvista repository. Is there any reason why we cannot do it that way here? |
From the pylint docs:
Similarly, for The mypy issue also requires we run this locally.
If you look at If you look at our |
@tkoyama010 I could be wrong, but I think we may need to do some work so that the We could probably leave |
@tkoyama010 Actually, I take that back: The
By default, Hence everytime We don't use namespace packages or monorepos, so I think instead using the Sometimes specifying
|
Close this as we now use https://pre-commit.ci/ . |
Create style_docstr.yml to run pre-commit