Skip to content

Commit a12326a

Browse files
authored
Merge pull request #168 from rstudio/pyright
2 parents d405f4f + c9e901e commit a12326a

File tree

7 files changed

+122
-10
lines changed

7 files changed

+122
-10
lines changed

.github/workflows/docs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ jobs:
7676
ALIAS: ${{ steps.deployment.outputs.env }}
7777

7878
- name: Update Github Deployment
79-
uses: bobheadxi/deployments@v0.4.3
80-
if: ${{ always() }}
79+
uses: bobheadxi/deployments@v1
80+
if: always()
8181
with:
8282
step: finish
8383
token: ${{ secrets.GITHUB_TOKEN }}
8484
status: ${{ job.status }}
85+
env: ${{ steps.deployment.outputs.env }}j
8586
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
8687
env_url: 'https://${{ steps.deployment.outputs.env }}--relaxed-mooncake-704252.netlify.app'
8788
logs: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'

.github/workflows/tests.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Install dependencies
3333
run: |
3434
python -m pip install --upgrade pip
35-
python -m pip install -e .[dev,torch,statsmodels,xgboost]
35+
python -m pip install -e ".[dev,all_models]"
3636
- name: Run Tests
3737
run: |
3838
pytest -m 'not rsc_test and not docker' --cov --cov-report xml
@@ -109,3 +109,32 @@ jobs:
109109
- name: Run tests
110110
run: |
111111
pytest vetiver/tests/test_sklearn.py
112+
113+
typecheck:
114+
runs-on: ubuntu-latest
115+
116+
# We want to run on external PRs, but not on our own internal PRs as they'll be run
117+
# by the push to the branch.
118+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
119+
120+
strategy:
121+
matrix:
122+
python-version: [3.11]
123+
124+
steps:
125+
- name: Checkout Code
126+
uses: actions/checkout@v3
127+
128+
- name: Setup Python
129+
uses: actions/setup-python@v4
130+
with:
131+
python-version: ${{ matrix.python-version }}
132+
133+
- name: Install Packages
134+
shell: bash
135+
run: |
136+
pip install ".[dev,all_models]"
137+
138+
- name: Run Tests
139+
shell: bash
140+
run: make typecheck

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,8 @@ dev-stop:
9191
docker-compose down
9292
rm -f $(RSC_API_KEYS)
9393

94+
typecheck:
95+
pyright
96+
9497
$(RSC_API_KEYS): dev-start
9598
python script/setup-rsconnect/dump_api_keys.py $@

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
# Catch-all target:
66
%: Makefile
77
python version_config.py
8-
python -m quartodoc build
8+
python -m quartodoc build --verbose
99
python -m quartodoc interlinks
1010
quarto render

pyproject.toml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,65 @@ markers = [
1818
[tool.setuptools_scm]
1919
fallback_version = "999"
2020
version_scheme = 'post-release'
21+
22+
########## Tool - Pyright ##########
23+
[tool.pyright]
24+
# Paths of directories or files that should be included. If no paths
25+
# are specified, pyright defaults to the directory that contains the
26+
# config file. Paths may contain wildcard characters ** (a directory or
27+
# multiple levels of directories), * (a sequence of zero or more
28+
# characters), or ? (a single character). If no include paths are
29+
# specified, the root path for the workspace is assumed.
30+
include = [
31+
"vetiver/"
32+
]
33+
34+
# Paths of directories or files whose diagnostic output (errors and
35+
# warnings) should be suppressed even if they are an included file or
36+
# within the transitive closure of an included file. Paths may contain
37+
# wildcard characters ** (a directory or multiple levels of
38+
# directories), * (a sequence of zero or more characters), or ? (a
39+
# single character).
40+
ignore = [
41+
#"vetiver/__init__.py",
42+
#"vetiver/attach_pkgs.py",
43+
"vetiver/helpers.py",
44+
"vetiver/meta.py",
45+
"vetiver/mock.py",
46+
"vetiver/model_card.py",
47+
"vetiver/monitor.py",
48+
"vetiver/pin_read_write.py",
49+
"vetiver/prototype.py",
50+
"vetiver/rsconnect.py",
51+
"vetiver/server.py",
52+
"vetiver/types.py",
53+
"vetiver/utils.py",
54+
"vetiver/vetiver_model.py",
55+
"vetiver/write_docker.py",
56+
"vetiver/write_fastapi.py",
57+
"vetiver/handlers/",
58+
"vetiver/data/",
59+
"vetiver/tests"
60+
]
61+
62+
# Set of identifiers that should be assumed to contain a constant
63+
# value wherever used within this program. For example, { "DEBUG": true
64+
# } indicates that pyright should assume that the identifier DEBUG will
65+
# always be equal to True. If this identifier is used within a
66+
# conditional expression (such as if not DEBUG:) pyright will use the
67+
# indicated value to determine whether the guarded block is reachable
68+
# or not. Member expressions that reference one of these constants
69+
# (e.g. my_module.DEBUG) are also supported.
70+
defineConstant = { DEBUG = true }
71+
72+
# typeCheckingMode = "strict"
73+
useLibraryCodeForTypes = true
74+
reportUnnecessaryTypeIgnoreComment = true
75+
76+
# Specifies a list of execution environments (see below). Execution
77+
# environments are searched from start to finish by comparing the path
78+
# of a source file with the root path specified in the execution
79+
# environment.
80+
executionEnvironments = []
81+
82+
stubPath = ""

setup.cfg

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ install_requires =
4141
[options.extras_require]
4242
all =
4343
vetiver[dev]
44+
vetiver[all_models]
45+
vetiver[docs]
46+
47+
all_models =
4448
vetiver[torch]
4549
vetiver[statsmodels]
4650
vetiver[xgboost]
@@ -49,15 +53,20 @@ dev =
4953
pytest
5054
pytest-cov
5155
pytest-snapshot
56+
vetiver[typecheck]
5257

5358
docs =
5459
quartodoc
5560

56-
torch =
57-
torch
58-
5961
statsmodels =
6062
statsmodels
6163

64+
torch =
65+
torch
66+
6267
xgboost =
6368
xgboost
69+
70+
typecheck =
71+
pyright
72+
pandas-stubs

vetiver/attach_pkgs.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
from __future__ import annotations
2+
import typing
3+
14
import tempfile
25
import os
36
import warnings
4-
from typing import List
57
from .vetiver_model import VetiverModel
68
from .meta import VetiverMeta
79

10+
if typing.TYPE_CHECKING:
11+
from typing import Optional
12+
from pathlib import Path
13+
814

9-
def load_pkgs(model: VetiverModel = None, packages: list = None, path=""):
15+
def load_pkgs(
16+
model: VetiverModel, packages: Optional[list] = None, path: str | Path = ""
17+
):
1018
"""Load packages necessary for predictions
1119
1220
Parameters
@@ -40,7 +48,7 @@ def load_pkgs(model: VetiverModel = None, packages: list = None, path=""):
4048
os.remove(tmp.name)
4149

4250

43-
def get_board_pkgs(board) -> List[str]:
51+
def get_board_pkgs(board) -> list[str]:
4452
"""
4553
Extract packages required for pin board authorization
4654

0 commit comments

Comments
 (0)