-
Notifications
You must be signed in to change notification settings - Fork 39
/
pyproject.toml
167 lines (148 loc) · 4.51 KB
/
pyproject.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "anywidget"
description = "custom jupyter widgets made easy"
authors = [
{ name = "Trevor Manz", email = "trevor.j.manz@gmail.com" }
]
license = { text = "MIT" }
dynamic = ["version"]
readme = "README.md"
requires-python = ">=3.7"
dependencies = [
"ipywidgets>=7.6.0",
"importlib-metadata; python_version < '3.8'",
"typing-extensions>=4.2.0",
"psygnal>=0.8.1",
]
[project.optional-dependencies]
test = [
"mypy==1.9.0; python_version > '3.7'",
"pydantic",
"pytest",
"pytest-cov",
"ruff",
"msgspec; python_version > '3.7'",
"ipython<8.13; python_version < '3.9'",
]
dev = [
"comm>=0.1.0",
"watchfiles>=0.18.0",
]
[project.urls]
homepage = "https://github.com/manzt/anywidget"
[tool.hatch.build.targets.wheel.shared-data]
"anywidget/nbextension" = "share/jupyter/nbextensions/anywidget"
"anywidget/labextension" = "share/jupyter/labextensions/anywidget"
"anywidget.json" = "etc/jupyter/nbconfig/notebook.d/anywidget.json"
[tool.hatch.build]
exclude = [
".github",
]
artifacts = [
"anywidget/nbextension/index.*",
"anywidget/labextension/*.tgz",
"anywidget/labextension",
]
[tool.hatch.build.hooks.jupyter-builder]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
"anywidget/nbextension/index.js",
"anywidget/labextension/package.json",
]
skip-if-exists = [
"anywidget/nbextension/index.js",
"anywidget/labextension/package.json",
]
dependencies = [
"hatch-jupyter-builder>=0.5.0",
]
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
npm = "pnpm"
build_cmd = "build"
[tool.hatch.version]
path = "packages/anywidget/package.json"
pattern = "\"version\": \"(?P<version>.+?)\""
[tool.hatch.envs.default]
features = ["test", "dev"]
[tool.hatch.envs.default.scripts]
lint = [
"ruff check {args:.}",
"ruff format --check --diff {args:.}",
]
fmt = [
"ruff format {args:.}",
"ruff check --fix {args:.}",
]
typecheck = "mypy anywidget"
test = "pytest . --cov anywidget --cov-report term-missing"
# https://github.com/charliermarsh/ruff
[tool.ruff]
line-length = 88
target-version = "py38"
src = ["anywidget", "tests"]
exclude = ["packages"]
[tool.ruff.lint]
extend-select = [
"E", # style errors
"F", # flakes
"D", # pydocstyle
"I", # isort
"UP", # pyupgrade
"RUF", # ruff-specific rules
]
# using this instead of tool.ruff.pydocstyle.convention until overrides
# are supported: https://github.com/charliermarsh/ruff/issues/2606
# specifically, we'd like to INCLUDE D417, which is not in the numpy convention
extend-ignore = [
"D100", # Missing docstring in public module
"D104", # Missing docstring in public package
"D107", # Missing docstring in __init__
"D203", # 1 blank line required before class docstring
"D212", # Multi-line docstring summary should start at the first line
"D213", # Multi-line docstring summary should start at the second line
"D401", # Imperative mood
"D413", # Missing blank line after last section
"D416", # Section name should end with a colon
"D206", # Docstring should be indented with spaces (delegate to `ruff format`)
"E501", # Line too long (delegate to `ruff format`)
]
[tool.ruff.lint.per-file-ignores]
"tests/*.py" = ["D", "S101"]
"docs/*.py" = ["D"]
# https://docs.pytest.org/en/latest/customize.html
[tool.pytest.ini_options]
minversion = "6.0"
testpaths = ["tests"]
filterwarnings = [
# this line turns warnings coming from anywidget into test errors
# best practice is to use pytest.warns to actually assert warnings happen
"error:::anywidget",
"ignore:Jupyter is migrating its paths:DeprecationWarning",
"ignore:Deprecated in traitlets 4.1, use the instance .metadata:DeprecationWarning",
]
# https://coverage.readthedocs.io/en/6.4/config.html
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
"@overload",
"except ImportError",
"\\.\\.\\.",
"raise NotImplementedError()"
]
# https://mypy.readthedocs.io/en/stable/config_file.html
[tool.mypy]
files = "anywidget/**/*.py"
strict = true
# this one is cumbersome, and not always that useful
disallow_any_generics = false
[[tool.mypy.overrides]]
module = "anywidget.widget" # makes heavy use of traitlets, which is not typed
disallow_untyped_calls = false
[[tool.mypy.overrides]]
# this might be missing in pre-commit, but they aren't typed anyway
module = ["ipywidgets", "traitlets.*", "comm", "IPython.*"]
ignore_missing_imports = true