Skip to content

Commit 0babed0

Browse files
committed
pre-commit: add .pre-commit-config.yaml
1 parent 230c069 commit 0babed0

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed

.pre-commit-config.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# pre-commit is a tool to perform a predefined set of tasks manually and/or
2+
# automatically before git commits are made.
3+
#
4+
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
5+
#
6+
# Common tasks
7+
#
8+
# - Run on all files: pre-commit run --all-files
9+
# - Register git hooks: pre-commit install --install-hooks
10+
#
11+
repos:
12+
# Autoformat: Python code, syntax patterns are modernized
13+
- repo: https://github.com/asottile/pyupgrade
14+
rev: v3.3.1
15+
hooks:
16+
- id: pyupgrade
17+
args:
18+
- --py38-plus
19+
20+
# Autoformat: Python code
21+
- repo: https://github.com/PyCQA/autoflake
22+
rev: v2.0.2
23+
hooks:
24+
- id: autoflake
25+
# args ref: https://github.com/PyCQA/autoflake#advanced-usage
26+
args:
27+
- --in-place
28+
29+
# Autoformat: Python code
30+
- repo: https://github.com/pycqa/isort
31+
rev: 5.12.0
32+
hooks:
33+
- id: isort
34+
35+
# Autoformat: Python code
36+
- repo: https://github.com/psf/black
37+
rev: 23.3.0
38+
hooks:
39+
- id: black
40+
41+
# Autoformat: markdown, yaml
42+
- repo: https://github.com/pre-commit/mirrors-prettier
43+
rev: v3.0.0-alpha.6
44+
hooks:
45+
- id: prettier
46+
47+
# Misc...
48+
- repo: https://github.com/pre-commit/pre-commit-hooks
49+
rev: v4.4.0
50+
# ref: https://github.com/pre-commit/pre-commit-hooks#hooks-available
51+
hooks:
52+
# Autoformat: Makes sure files end in a newline and only a newline.
53+
- id: end-of-file-fixer
54+
55+
# Autoformat: Sorts entries in requirements.txt.
56+
- id: requirements-txt-fixer
57+
58+
# Lint: Check for files with names that would conflict on a
59+
# case-insensitive filesystem like MacOS HFS+ or Windows FAT.
60+
- id: check-case-conflict
61+
62+
# Lint: Checks that non-binary executables have a proper shebang.
63+
- id: check-executables-have-shebangs
64+
65+
# Lint: Python code
66+
- repo: https://github.com/PyCQA/flake8
67+
rev: "6.0.0"
68+
hooks:
69+
- id: flake8
70+
71+
# pre-commit.ci config reference: https://pre-commit.ci/#configuration
72+
ci:
73+
autoupdate_schedule: monthly

pyproject.toml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# build-system
2+
# - ref: https://peps.python.org/pep-0517/
3+
#
14
[build-system]
25
build-backend = "hatchling.build"
36
requires = [
@@ -7,6 +10,11 @@ requires = [
710
"jupyterlab >=3.4.7,<4.0.0",
811
]
912

13+
14+
# project
15+
# - ref 1: https://peps.python.org/pep-0621/
16+
# - ref 2: https://hatch.pypa.io/latest/config/metadata/#project-metadata
17+
#
1018
[project]
1119
name = "jupyter_server_proxy"
1220
dynamic = [
@@ -56,6 +64,7 @@ acceptance = [
5664
"robotframework-jupyterlibrary >=0.4.2",
5765
]
5866

67+
5968
[tool.hatch.version]
6069
source = "nodejs"
6170
path = "labextension/package.json"
@@ -68,6 +77,7 @@ exclude = [
6877
".git",
6978
".github",
7079
".readthedocs.yaml",
80+
".pre-commit-config.yaml",
7181
"contrib",
7282
"docs",
7383
]
@@ -102,6 +112,41 @@ npm = ["jlpm"]
102112
source_dir = "labextension/src"
103113
build_dir = "jupyter_server_proxy/labextension"
104114

115+
116+
# autoflake is used for autoformatting Python code
117+
#
118+
# ref: https://github.com/PyCQA/autoflake#readme
119+
#
120+
[tool.autoflake]
121+
ignore-init-module-imports = true
122+
remove-all-unused-imports = true
123+
remove-duplicate-keys = true
124+
remove-unused-variables = true
125+
126+
127+
# black is used for autoformatting Python code
128+
#
129+
# ref: https://black.readthedocs.io/en/stable/
130+
#
131+
[tool.black]
132+
# target-version should be all supported versions, see
133+
# https://github.com/psf/black/issues/751#issuecomment-473066811
134+
target_version = [
135+
"py38",
136+
"py39",
137+
"py310",
138+
"py311",
139+
]
140+
141+
142+
# isort is used for autoformatting Python code
143+
#
144+
# ref: https://pycqa.github.io/isort/
145+
#
146+
[tool.isort]
147+
profile = "black"
148+
149+
105150
# tbump is used to simplify and standardize the release process when updating
106151
# the version, making a git commit and tag, and pushing changes.
107152
#

0 commit comments

Comments
 (0)