Skip to content

Commit

Permalink
Feature/250 add pyright (#256)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nathanjmcdougall authored Jul 25, 2024
1 parent 8e97eda commit d821b76
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 4 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,20 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]

pyright:
name: "Run Pyright"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.12 # Use the maximum version supported by python-pins
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install -e .[check]
- uses: jakebailey/pyright-action@v2
with:
version: 1.1.372 # Manually sync with setup.cfg
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ docs-clean:
requirements/dev.txt: setup.cfg
@# allows you to do this...
@# make requirements | tee > requirements/some_file.txt
@pip-compile setup.cfg --rebuild --extra doc --extra test --output-file=- > $@
@pip-compile setup.cfg --rebuild --extra doc --extra test --extra check --output-file=- > $@

binder/requirements.txt: requirements/dev.txt
cp $< $@
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pins
<a href="https://rstudio.github.io/pins-python/"><img src="docs/logo.png" align="right" height="138" /></a>

![PyPI - Version](https://img.shields.io/pypi/v/pins.svg) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pins)
![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/)



Expand Down
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ dependencies = [
[project.optional-dependencies]
aws = ["s3fs"]
azure = ["adlfs"]
check = [
"pre-commit",
"pyright==1.1.372", # Pinned; manually sync with .github/workflows/code-checks.yml
"types-appdirs",
]
doc = [
"ipykernel",
"ipython<=8.12",
Expand Down Expand Up @@ -85,6 +90,31 @@ testpaths = ["pins"]
addopts = "--doctest-modules"
doctest_optionflags = "NORMALIZE_WHITESPACE"

[tool.pyright]
include = ["pins"]
exclude = ["**/__pycache__"]
ignore = ["pins/tests"]
pythonVersion = "3.12" # Use the maximum version supported by python-pins
pythonPlatform = "Linux"

# Tracking compliance with these rules at https://github.com/rstudio/pins-python/issues/272
reportArgumentType = false
reportAssignmentType = false
reportAttributeAccessIssue = false
reportCallIssue = false
reportGeneralTypeIssues = false
reportIncompatibleMethodOverride = false
reportIncompatibleVariableOverride = false
reportIndexIssue = false
reportMissingImports = false
reportMissingTypeStubs = false
reportOptionalIterable = false
reportOptionalMemberAccess = false
reportOptionalSubscript = false
reportPossiblyUnboundVariable = false
reportReturnType = false
reportUnusedExpression = false

[tool.ruff]
line-length = 90
extend-exclude = ["docs"]
Expand Down
27 changes: 25 additions & 2 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --extra=doc --extra=test --output-file=- --strip-extras setup.cfg
# pip-compile --extra=doc --extra=test --extra=check --output-file=- --strip-extras setup.cfg
#
--index-url https://pypi.python.org/simple/
--trusted-host pypi.org
Expand Down Expand Up @@ -67,6 +67,8 @@ cffi==1.16.0
# via
# azure-datalake-store
# cryptography
cfgv==3.4.0
# via pre-commit
charset-normalizer==3.3.2
# via requests
click==8.1.7
Expand All @@ -93,12 +95,16 @@ decorator==5.1.1
# via
# gcsfs
# ipython
distlib==0.3.8
# via virtualenv
executing==2.0.1
# via stack-data
fastjsonschema==2.20.0
# via nbformat
fastparquet==2024.5.0
# via pins (setup.cfg)
filelock==3.15.4
# via virtualenv
frozenlist==1.4.1
# via
# aiohttp
Expand Down Expand Up @@ -141,6 +147,8 @@ griffe==0.48.0
# via quartodoc
humanize==4.10.0
# via pins (setup.cfg)
identify==2.6.0
# via pre-commit
idna==3.7
# via
# requests
Expand Down Expand Up @@ -220,6 +228,10 @@ nbformat==5.10.4
# pins (setup.cfg)
nest-asyncio==1.6.0
# via ipykernel
nodeenv==1.9.1
# via
# pre-commit
# pyright
numpy==2.0.0
# via
# fastparquet
Expand Down Expand Up @@ -247,13 +259,17 @@ pickleshare==0.7.5
pip-tools==7.4.1
# via pins (setup.cfg)
platformdirs==4.2.2
# via jupyter-core
# via
# jupyter-core
# virtualenv
pluggy==1.5.0
# via pytest
plum-dispatch==2.5.1.post1
# via quartodoc
portalocker==2.10.1
# via msal-extensions
pre-commit==3.7.1
# via pins (setup.cfg)
prompt-toolkit==3.0.47
# via ipython
proto-plus==1.24.0
Expand Down Expand Up @@ -297,6 +313,8 @@ pyproject-hooks==1.1.0
# via
# build
# pip-tools
pyright==1.1.372
# via pins (setup.cfg)
pytest==7.1.3
# via
# pins (setup.cfg)
Expand All @@ -320,6 +338,7 @@ pytz==2024.1
pyyaml==6.0.1
# via
# pins (setup.cfg)
# pre-commit
# quartodoc
pyzmq==26.0.3
# via
Expand Down Expand Up @@ -384,6 +403,8 @@ traitlets==5.14.3
# matplotlib-inline
# nbclient
# nbformat
types-appdirs==1.4.3.5
# via pins (setup.cfg)
typing-extensions==4.12.2
# via
# azure-core
Expand All @@ -398,6 +419,8 @@ urllib3==2.2.2
# via
# botocore
# requests
virtualenv==20.26.3
# via pre-commit
watchdog==4.0.1
# via quartodoc
wcwidth==0.2.13
Expand Down

0 comments on commit d821b76

Please sign in to comment.