Skip to content

Commit

Permalink
Merge pull request #36 from asmeurer/pre-commit
Browse files Browse the repository at this point in the history
Enable pre-commit
  • Loading branch information
Saransh-cpp authored Sep 4, 2023
2 parents 685b628 + 3a5b0c3 commit 9b80fd3
Show file tree
Hide file tree
Showing 11 changed files with 1,434 additions and 723 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# activated pre-commit - https://github.com/asmeurer/removestar/pull/36
aa3a9ba0bffb194670484ec6bdb35cc4ce645330
18 changes: 12 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@ name: Build removestar

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

env:
SHELLOPTS: errexit:nounset:pipefail

jobs:
pre-commit:
runs-on: ubuntu-latest
name: Check SDist
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: pre-commit/[email protected]

build:
runs-on: ubuntu-latest
strategy:
Expand All @@ -25,10 +35,6 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pyflakes pytest pytest-doctestplus ruff
- name: Lint
run: |
ruff --select=A,B,E,F,PLC,PLE,PLW,SIM,W --ignore=B023,B904,E402,PLC1901,SIM115,B018 --line-length=263 --statistics .
python -We:invalid -We::SyntaxWarning -m compileall -f -q removestar/
- name: Install
run: |
python -m pip install .
Expand Down
69 changes: 69 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"

repos:
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black-jupyter

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: ^docs
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.282"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]

# TODO: add static types
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.4.1
# hooks:
# - id: mypy
# files: src
# args: []
# additional_dependencies:
# - numpy
# - packaging

- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
- id: codespell

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.1"
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
exclude: assets/js/webapp\.js

- repo: https://github.com/asottile/blacken-docs
rev: 1.15.0
hooks:
- id: blacken-docs
args: ["-E"]
additional_dependencies: [black==23.1.0]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-type-ignore
exclude: ^src/vector/backends/_numba_object.py$
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,53 @@
# 1.3.1 (2021-09-02)

## Bug Fixes

- Fix the line wrapping logic to always wrap import lines if they are greater
than the max line length (previously it would not account for the last
imported name in the line).

# 1.3 (2021-08-24)

## New Features

- Lines with star imports can now contain comments.
- Star imports can be whitelisted using `# noqa` comments.
- Replaced Travis CI with GitHub Actions.

Thanks to [@h4l](https://github.com/h4l) for these improvements.

# 1.2.4 (2021-08-16)

## Bug Fixes

- Fix an incorrectly done release from 1.2.3.

# 1.2.3 (2021-08-16)

## Bug Fixes

- Fix unformatted module name placeholder in "Could not find the star imports"
warning (thanks to [@h4l](https://github.com/h4l)).

# 1.2.2 (2019-08-22)

## Bug Fixes

- Names that are used more than once no longer produce duplicate imports.
- Files are no longer read redundantly.
- Files are no longer written into if the code does not change.
- A blank line is no longer printed for empty diffs.

# 1.2.1 (2019-08-17)

## Bug Fixes

- Imports that are completely removed are no longer replaced with a blank line.

# 1.2 (2019-08-16)

## New Features

- removestar now works correctly with recursive star imports. In particular,
`from .submod import *` now works when submod is a submodule whose
`__init__.py` itself uses `import *` (removestar still skips `__init__.py`
Expand All @@ -46,15 +58,19 @@ Thanks to [@h4l](https://github.com/h4l) for these improvements.
- Better error message for same-module absolute imports that don't exist.

## Bug Fixes

- Don't consider `__builtins__` to be imported from external modules (even
though it technically is).
- Make sure pytest-doctestplus is installed when running the tests.

## Other

- Include the LICENSE file in the distribution and the setup.py metadata.

# 1.1 (2019-08-05)

## New Features

- Add `--verbose` and `--quiet` flags. `--verbose` prints about every name that an
import is added for. `--quiet` hides all warning output.
- Add support for absolute imports. Absolute imports from the same module are
Expand All @@ -63,25 +79,30 @@ Thanks to [@h4l](https://github.com/h4l) for these improvements.
be disabled with the flag `--no-dynamic-importing`.
- Add `--max-line-length` to control the line length at which imports are
wrapped. The default is 100. It can be disabled with `remoevstar
--max-line-length 0`.
--max-line-length 0`.
- No longer stop traversing a directory when encountering a file with invalid
syntax.

## Bug Fixes

- Fix logic for wrapping long imports
- Fix the filename in some error messages.

## Other

- Add tests.
- Move all TODOs to the GitHub issue tracker.

# 1.0.1 (2019-07-18)

## New Features

- Automatically skip non-.py files
- Automatically skip `__init__.py`
- Add flag `--no-skip-init` to not skip `__init__.py`

## Bug Fixes

- Fix directory recursion
- Fix multiline import logic

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Some reasons why `import *` is bad:
underscore) name defined in the module file. This can often include things
like standard library imports or loop variables defined at the top-level of
the file. For imports from modules (from `__init__.py`), `from module import
*` will include every submodule defined in that module. Using `__all__` in
*` will include every submodule defined in that module. Using `__all__` in
modules and `__init__.py` files is also good practice, as these things are
also often confusing even for interactive use where `import *` is
acceptable.
Expand Down
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
theme: jekyll-theme-merlot
theme: jekyll-theme-merlot
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ select = [
"YTT", # flake8-2020
]
extend-ignore = [
"E501", # Line too long
"E501", # Line too long
"PLR0915", # Too many statements
"PLR0913", # Too many arguments to function call
"T201", # Print statements
"B904", # Raise exception with `raise ... from err`
"B023", # Function definition does not bind loop variable
]
src = ["src"]
unfixable = [
Expand Down
Loading

0 comments on commit 9b80fd3

Please sign in to comment.