Skip to content

Commit

Permalink
Migrating anaconda-linter to the Packaging Automation Team Standards
Browse files Browse the repository at this point in the history
- `percy` and `perseverance-scripts` walked so `anaconda-linter` could run
- Backports the configurations and learnings from our previous projects to
  provide a more consistent and convenient set of automated code checks
- Not all of these rules will be enforced at this time. Expect an auto-
  formatter PR in the near term, but the `pylint` and `mypy` rules will be
  much futher down the line
  • Loading branch information
schuylermartin45 committed Oct 20, 2023
1 parent e46317d commit 7cc1b96
Show file tree
Hide file tree
Showing 10 changed files with 596 additions and 92 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[run]
omit =
tests/*
*/__init__.py
21 changes: 0 additions & 21 deletions .editorconfig

This file was deleted.

3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

38 changes: 38 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[mypy]
# Adapted from this StackOverflow post:
# https://stackoverflow.com/questions/55944201/python-type-hinting-how-do-i-enforce-that-project-wide
python_version = 3.11

# This flag enhances the user feedback for error messages
pretty = True

# Disallow dynamic typing
disallow_any_unimported = True
disallow_any_expr = True
disallow_any_decorated = True
disallow_any_generics = True
disallow_any_explicit = True
disallow_subclassing_any = True

# Disallow untyped definitions and calls
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True

# None and optional handling
no_implicit_optional = True

# Configuring warnings
warn_unused_ignores = True
warn_no_return = True
warn_return_any = True
warn_redundant_casts = True
warn_unreachable = True

# Misc things
strict_equality = True

# Config file
warn_unused_configs = True
63 changes: 45 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@
# pre-commit run --all-files
# Update this file:
# pre-commit autoupdate
exclude: tests/test_aux_files/.*
# TODO remove when other files are updated to pass. NOTE: keep the first line
# as-is.
exclude: |
(?x)^(
tests/test_aux_files/.*|
anaconda_linter/.*|
docs/.*|
scripts/.*|
setup.py|
tests/.*
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
exclude_types: ["json", "yaml"]
- id: check-ast
- id: fix-byte-order-marker
- id: check-case-conflict
Expand All @@ -21,31 +32,28 @@ repos:
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
# Notes:
# - By default, `black` uses a line-length of 88.
# - `isort` will conflict with `black`, if not properly configured
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", --line-length=120]
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.10.0
hooks:
- id: black
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
- id: black
args: [--line-length=120]
- repo: https://github.com/PyCQA/pylint
rev: v3.0.1
hooks:
- id: pyupgrade
args: [--py37-plus, --keep-runtime-typing]
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
- id: pylint
args: ["--rcfile=.pylintrc"]
- repo: https://github.com/lovesegfault/beautysh
rev: v6.2.1
hooks:
- id: beautysh
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
- id: shellcheck
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
hooks:
Expand All @@ -57,7 +65,26 @@ repos:
hooks:
- id: codespell
args: [--write]
- repo: meta
- repo: local
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
# Run shellcheck without needing `docker` to run
- id: shellcheck
name: shellcheck
description: Test shell scripts with shellcheck
entry: shellcheck
language: python
types: [shell]
require_serial: true # shellcheck can detect sourcing this way
# Run tests through `make` to be consistent with manually run commands.
- id: pytest
language: system
name: pytest
always_run: true
pass_filenames: false
entry: make test
- id: pytest-cov
language: system
name: pytest-cov
always_run: true
pass_filenames: false
entry: make test-cov
Loading

0 comments on commit 7cc1b96

Please sign in to comment.