Skip to content

Commit

Permalink
pip upgrade and ruff (#26)
Browse files Browse the repository at this point in the history
* pip upgrade and ruff

* line length

* rm useless comment

* no e704

* more ruff config

* fewer constraints, gitignore and readme

* updated pre-commit
  • Loading branch information
cristianmatache committed Mar 16, 2024
1 parent 9075a75 commit 20b4eb7
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 111 deletions.
19 changes: 8 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
repos:
# YAML auto-formatters
- repo: https://github.com/lyz-code/yamlfix/
rev: 0.9.0
rev: 1.16.0
hooks:
- id: yamlfix
exclude: (.*ci.yml|.*.yamllint.yaml|.*.markdownlint.yml|.*.prettierrc.yaml)
# Prettier auto-formatter
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.2
rev: v4.0.0-alpha.8
hooks:
- id: prettier
args: [--config=.prettierrc.yaml]
exclude: (.*ci.yml|.*.yamllint.yaml|.*.markdownlint.yml|.*.prettierrc.yaml)
# GENERAL
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
Expand All @@ -32,23 +32,20 @@ repos:
- id: check-added-large-files
# Python auto-formatters
- repo: https://github.com/PyCQA/autoflake
rev: v1.4
rev: v2.3.1
hooks:
- id: autoflake
args:
- --in-place
- --remove-all-unused-imports
- --remove-unused-variables
- repo: https://github.com/PyCQA/docformatter
rev: v1.4
rev: v1.7.5
hooks:
- id: docformatter
args:
- --in-place
- --wrap-summaries=120
- --wrap-descriptions=120
args: [--in-place, --wrap-summaries=120, --wrap-descriptions=120]
- repo: https://github.com/ikamensh/flynt
rev: '0.76'
rev: 1.0.1
hooks:
- id: flynt
# BASH auto-formatters
Expand All @@ -59,7 +56,7 @@ repos:
args: [-i=4]
# Markdown lint
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.31.1
rev: v0.39.0
hooks:
- id: markdownlint
args: [--config=.markdownlint.yml]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cd <your-project>
Create and activate the environment, e.g. with conda

```bash
conda create -n my-env python=3.9 -y
conda create -n my-env python=3.10 -y
conda activate my-env
```

Expand Down Expand Up @@ -74,12 +74,14 @@ have fixed the issues).
make lint
```

If you haven't set up make on your machine, you can try running `pre-commit run --all-files`.
Let's test whether testing works as well.

```bash
make test
```

Again, if you haven't set up make on your machine, you can try running `pytest --rootdir=. -m "" -k ""tests/`.
To test whether everything works with multiple Python versions, run the same tests but with "nox".

```bash
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.yamlfix]
preserve_quotes = true
3 changes: 3 additions & 0 deletions {{cookiecutter.repo_name}}/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,6 @@ dmypy.json

# Pyre type checker
.pyre/

# Flakeheaven
.flakeheaven_cache/
43 changes: 24 additions & 19 deletions {{cookiecutter.repo_name}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ exclude: build-support/alpha-build/core|build-support/git-bash-integration
repos:
# YAML auto-formatters
- repo: https://github.com/lyz-code/yamlfix/
rev: ''
rev: ""
hooks:
# On Windows, this writes \r\n newlines that need to be fixed by the next hook
- id: yamlfix
# Prettier auto-formatter
- repo: https://github.com/pre-commit/mirrors-prettier
rev: ''
rev: ""
hooks:
# On Windows, this writes \r\n newlines that need to be fixed by the next hook
- id: prettier
# GENERAL
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: ''
rev: ""
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
Expand All @@ -29,37 +29,44 @@ repos:
- id: check-added-large-files
# Python auto-formatters
- repo: https://github.com/PyCQA/autoflake
rev: ''
rev: ""
hooks:
- id: autoflake
args:
- --in-place
- --remove-all-unused-imports
- --remove-unused-variables
- repo: https://github.com/PyCQA/docformatter
rev: ''
rev: ""
hooks:
- id: docformatter
args:
- --in-place
- --wrap-summaries={{cookiecutter.line_length}}
- --wrap-descriptions={{cookiecutter.line_length}}
- repo: https://github.com/ikamensh/flynt
rev: ''
rev: ""
hooks:
- id: flynt
- repo: https://github.com/pycqa/isort
rev: ''
rev: ""
hooks:
- id: isort
name: isort (python)
args: [--settings-path=pyproject.toml]
# Black also applies to notebooks
- repo: https://github.com/psf/black
rev: ''
rev: ""
hooks:
- id: black
args: [--config=pyproject.toml]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: ""
hooks:
- id: ruff-format
name: ruff format
- id: ruff
name: ruff lint
# Python linters
- repo: local
hooks:
Expand All @@ -69,49 +76,47 @@ repos:
language: system
types_or: [python, pyi]
- repo: https://github.com/flakeheaven/flakeheaven
rev: ''
rev: ""
hooks:
- id: flakeheaven
additional_dependencies:
- wemake-python-styleguide
- flake8-annotations
additional_dependencies: [wemake-python-styleguide, flake8-annotations]
- repo: https://github.com/Lucas-C/pre-commit-hooks-bandit
rev: ''
rev: ""
hooks:
- id: python-bandit-vulnerability-check
name: bandit
args: [--configfile pyproject.toml]
- repo: https://github.com/pycqa/pylint
rev: ''
rev: ""
hooks:
- id: pylint
args: [--rcfile=pyproject.toml]
# JUPYTER auto-formatters
- repo: https://github.com/kynan/nbstripout
rev: ''
rev: ""
hooks:
- id: nbstripout
# BASH auto-formatters
- repo: https://github.com/cisagov/pre-commit-shfmt
rev: ''
rev: ""
hooks:
- id: shfmt
args: [-i=4]
# BASH linter
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: ''
rev: ""
hooks:
- id: shellcheck
args: [-x]
# YAML linters
- repo: https://github.com/adrienverge/yamllint.git
rev: ''
rev: ""
hooks:
- id: yamllint
args: [-c=.yamllint.yaml]
# Markdown lint
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: ''
rev: ""
hooks:
- id: markdownlint
args: [--config=.markdownlint.yml]
Expand Down
78 changes: 1 addition & 77 deletions {{cookiecutter.repo_name}}/3rdparty/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,77 +1 @@
alabaster==0.7.12
argcomplete==1.12.3
atomicwrites==1.4.0
attrs==21.4.0
Babel==2.10.3
bleach==5.0.1
build==0.8.0
bump2version==1.0.1
certifi==2021.10.8
cfgv==3.3.1
charset-normalizer==2.1.0
colorama==0.4.4
colorlog==6.6.0
commonmark==0.9.1
coverage==6.3.3
distlib==0.3.4
docutils==0.18.1
filelock==3.7.0
greenlet==1.1.2
identify==2.5.1
idna==3.3
imagesize==1.4.1
importlib-metadata==4.12.0
iniconfig==1.1.1
Jinja2==3.1.2
keyring==23.6.0
MarkupSafe==2.1.1
mypy==0.950
mypy-extensions==0.4.3
nodeenv==1.6.0
nox==2022.1.7
packaging==21.3
pep517==0.12.0
pip==22.1.2
pkginfo==1.8.3
platformdirs==2.5.2
pluggy==1.0.0
pre-commit==2.19.0
py==1.11.0
pydantic==1.9.1
Pygments==2.12.0
pyparsing==3.0.9
pytest==7.1.2
pytest-cov==3.0.0
pytz==2022.1
pywin32-ctypes==0.2.0
PyYAML==6.0
readme-renderer==35.0
requests==2.28.1
requests-toolbelt==0.9.1
rfc3986==2.0.0
rich==12.4.4
setuptools==63.1.0
shfmt-py==3.4.3.1
six==1.16.0
snowballstemmer==2.2.0
Sphinx==5.0.2
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
SQLAlchemy==1.4.36
sqlalchemy2-stubs==0.0.2a22
toml==0.10.2
tomli==2.0.1
twine==4.0.1
types-requests==2.28.0
types-urllib3==1.26.16
typing_extensions==4.2.0
urllib3==1.26.10
virtualenv==20.14.1
webencodings==0.5.1
wheel==0.37.1
wincertstore==0.2
zipp==3.8.0
typing_extensions==4.10.0
2 changes: 1 addition & 1 deletion {{cookiecutter.repo_name}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ env:
.PHONY: env-upgrade
env-upgrade:
$(python) -m pip install --upgrade pip setuptools
$(python) -m pip install -r 3rdparty/requirements.txt -r 3rdparty/requirements-dev.txt
$(python) -m pip install --upgrade -r 3rdparty/requirements.txt -r 3rdparty/requirements-dev.txt
$(python) -m pip list --format=freeze > 3rdparty/constraints.txt

.PHONY: wheel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ source "$GIT_BASH_UTILS_LIB_ROOT/utils.sh"
# https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058
echo "Installing make"

MAKE_DOWNLOAD_URL="https://sourceforge.net/projects/ezwinports/files/make-4.4-without-guile-w32-bin.zip/download"
MAKE_DOWNLOAD_URL="https://sourceforge.net/projects/ezwinports/files/make-4.4.1-without-guile-w32-bin.zip/download"
curl -kL $MAKE_DOWNLOAD_URL --output install_make.zip
unzip install_make.zip -d install_make
rm install_make.zip
Expand Down
31 changes: 30 additions & 1 deletion {{cookiecutter.repo_name}}/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[tool.pytest.ini_options]
addopts = "--cov={{cookiecutter.package_name}} --cov-fail-under={{cookiecutter.min_test_coverage}} -vv --durations=10 --cov-report html --cov-report xml"

[tool.yamlfix]
preserve_quotes = true

[tool.isort]
profile = 'black'
line_length = '{{cookiecutter.line_length}}'
Expand Down Expand Up @@ -36,7 +39,7 @@ flake8-pytest-style = ["+*"]
flake8-spellcheck = ["+*"]
mccabe = ["+*"]
pep8-naming = ["+*"]
pycodestyle = ["+*", "-E203", "-W503"]
pycodestyle = ["+*", "-E203", "-E704", "-E999", "-W503"]
pyflakes = ["+*"]
#pylint = ["+*"] # Uncomment if you want to enable pylint and use it on top of the baseline
#flake8-bandit = ["+*"]
Expand Down Expand Up @@ -79,3 +82,29 @@ ignore_whitespace = true
#ignore_unstaged = true
show_uncovered = false
#quiet = true

[tool.ruff]
extend-exclude = [
".idea",
"build-support",
]
line-length = '{{cookiecutter.line_length}}'
indent-width = 4

[tool.ruff.format]
quote-style = "single"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "lf"

[tool.ruff.lint]
select = []
ignore = [
"Q000", "ANN101", "RUF100", "S101",
]
fixable = ["ALL"]

[tool.ruff.lint.per-file-ignores]
"**/{tests}/*" = ["ALL"]

[tool.ruff.lint.isort]

0 comments on commit 20b4eb7

Please sign in to comment.