Skip to content

Commit d821b76

Browse files
Feature/250 add pyright (#256)
* Add a new `check` extra including `pyright` and `pre-commit`. * Configure pyright to run in CI. * Use pyright action v2 * Install dependencies before running pyright. * Fix sync error. * Revert unnecessary bumps in dev.txt * Ignore the tests folder correctly. * Add appdirs stubs * Re-enable reportUnusedExpression * Add triaging comments for rule disables * Revert unnecessary project.toml formatting change * Revert unnecessary indentation in dev.txt * Update pyproject.toml Co-authored-by: Isabel Zimmerman <[email protected]> * Move pyright comments to a tracking issue. * Revert removal of config sections in pyproject.toml. * add check deps into toml
1 parent 8e97eda commit d821b76

File tree

5 files changed

+74
-4
lines changed

5 files changed

+74
-4
lines changed

.github/workflows/code-checks.yml

+17
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,20 @@ jobs:
1616
- uses: actions/checkout@v4
1717
- uses: actions/setup-python@v4
1818
- uses: pre-commit/[email protected]
19+
20+
pyright:
21+
name: "Run Pyright"
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-python@v4
26+
with:
27+
python-version: 3.12 # Use the maximum version supported by python-pins
28+
- name: Install dependencies
29+
shell: bash
30+
run: |
31+
python -m pip install --upgrade pip
32+
python -m pip install -e .[check]
33+
- uses: jakebailey/pyright-action@v2
34+
with:
35+
version: 1.1.372 # Manually sync with setup.cfg

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ docs-clean:
4141
requirements/dev.txt: setup.cfg
4242
@# allows you to do this...
4343
@# make requirements | tee > requirements/some_file.txt
44-
@pip-compile setup.cfg --rebuild --extra doc --extra test --output-file=- > $@
44+
@pip-compile setup.cfg --rebuild --extra doc --extra test --extra check --output-file=- > $@
4545

4646
binder/requirements.txt: requirements/dev.txt
4747
cp $< $@

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# pins
22
<a href="https://rstudio.github.io/pins-python/"><img src="docs/logo.png" align="right" height="138" /></a>
33

4-
![PyPI - Version](https://img.shields.io/pypi/v/pins.svg) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pins)
4+
![PyPI - Version](https://img.shields.io/pypi/v/pins.svg) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pins) [![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
55

66

77

pyproject.toml

+30
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ dependencies = [
3636
[project.optional-dependencies]
3737
aws = ["s3fs"]
3838
azure = ["adlfs"]
39+
check = [
40+
"pre-commit",
41+
"pyright==1.1.372", # Pinned; manually sync with .github/workflows/code-checks.yml
42+
"types-appdirs",
43+
]
3944
doc = [
4045
"ipykernel",
4146
"ipython<=8.12",
@@ -85,6 +90,31 @@ testpaths = ["pins"]
8590
addopts = "--doctest-modules"
8691
doctest_optionflags = "NORMALIZE_WHITESPACE"
8792

93+
[tool.pyright]
94+
include = ["pins"]
95+
exclude = ["**/__pycache__"]
96+
ignore = ["pins/tests"]
97+
pythonVersion = "3.12" # Use the maximum version supported by python-pins
98+
pythonPlatform = "Linux"
99+
100+
# Tracking compliance with these rules at https://github.com/rstudio/pins-python/issues/272
101+
reportArgumentType = false
102+
reportAssignmentType = false
103+
reportAttributeAccessIssue = false
104+
reportCallIssue = false
105+
reportGeneralTypeIssues = false
106+
reportIncompatibleMethodOverride = false
107+
reportIncompatibleVariableOverride = false
108+
reportIndexIssue = false
109+
reportMissingImports = false
110+
reportMissingTypeStubs = false
111+
reportOptionalIterable = false
112+
reportOptionalMemberAccess = false
113+
reportOptionalSubscript = false
114+
reportPossiblyUnboundVariable = false
115+
reportReturnType = false
116+
reportUnusedExpression = false
117+
88118
[tool.ruff]
89119
line-length = 90
90120
extend-exclude = ["docs"]

requirements/dev.txt

+25-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is autogenerated by pip-compile with Python 3.11
33
# by the following command:
44
#
5-
# pip-compile --extra=doc --extra=test --output-file=- --strip-extras setup.cfg
5+
# pip-compile --extra=doc --extra=test --extra=check --output-file=- --strip-extras setup.cfg
66
#
77
--index-url https://pypi.python.org/simple/
88
--trusted-host pypi.org
@@ -67,6 +67,8 @@ cffi==1.16.0
6767
# via
6868
# azure-datalake-store
6969
# cryptography
70+
cfgv==3.4.0
71+
# via pre-commit
7072
charset-normalizer==3.3.2
7173
# via requests
7274
click==8.1.7
@@ -93,12 +95,16 @@ decorator==5.1.1
9395
# via
9496
# gcsfs
9597
# ipython
98+
distlib==0.3.8
99+
# via virtualenv
96100
executing==2.0.1
97101
# via stack-data
98102
fastjsonschema==2.20.0
99103
# via nbformat
100104
fastparquet==2024.5.0
101105
# via pins (setup.cfg)
106+
filelock==3.15.4
107+
# via virtualenv
102108
frozenlist==1.4.1
103109
# via
104110
# aiohttp
@@ -141,6 +147,8 @@ griffe==0.48.0
141147
# via quartodoc
142148
humanize==4.10.0
143149
# via pins (setup.cfg)
150+
identify==2.6.0
151+
# via pre-commit
144152
idna==3.7
145153
# via
146154
# requests
@@ -220,6 +228,10 @@ nbformat==5.10.4
220228
# pins (setup.cfg)
221229
nest-asyncio==1.6.0
222230
# via ipykernel
231+
nodeenv==1.9.1
232+
# via
233+
# pre-commit
234+
# pyright
223235
numpy==2.0.0
224236
# via
225237
# fastparquet
@@ -247,13 +259,17 @@ pickleshare==0.7.5
247259
pip-tools==7.4.1
248260
# via pins (setup.cfg)
249261
platformdirs==4.2.2
250-
# via jupyter-core
262+
# via
263+
# jupyter-core
264+
# virtualenv
251265
pluggy==1.5.0
252266
# via pytest
253267
plum-dispatch==2.5.1.post1
254268
# via quartodoc
255269
portalocker==2.10.1
256270
# via msal-extensions
271+
pre-commit==3.7.1
272+
# via pins (setup.cfg)
257273
prompt-toolkit==3.0.47
258274
# via ipython
259275
proto-plus==1.24.0
@@ -297,6 +313,8 @@ pyproject-hooks==1.1.0
297313
# via
298314
# build
299315
# pip-tools
316+
pyright==1.1.372
317+
# via pins (setup.cfg)
300318
pytest==7.1.3
301319
# via
302320
# pins (setup.cfg)
@@ -320,6 +338,7 @@ pytz==2024.1
320338
pyyaml==6.0.1
321339
# via
322340
# pins (setup.cfg)
341+
# pre-commit
323342
# quartodoc
324343
pyzmq==26.0.3
325344
# via
@@ -384,6 +403,8 @@ traitlets==5.14.3
384403
# matplotlib-inline
385404
# nbclient
386405
# nbformat
406+
types-appdirs==1.4.3.5
407+
# via pins (setup.cfg)
387408
typing-extensions==4.12.2
388409
# via
389410
# azure-core
@@ -398,6 +419,8 @@ urllib3==2.2.2
398419
# via
399420
# botocore
400421
# requests
422+
virtualenv==20.26.3
423+
# via pre-commit
401424
watchdog==4.0.1
402425
# via quartodoc
403426
wcwidth==0.2.13

0 commit comments

Comments
 (0)