-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v2: Add lint and type checking for Python package (#515)
* ruff format * Initial lint fix * Initial ruff lint passing * Add mypy type checking * Add ci check * Add py.typed * ignore mypy errors in jupyter widget * fix imports * bump min version to Python 3.9 * numpy < 2
- Loading branch information
Showing
183 changed files
with
3,880 additions
and
3,299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,29 @@ jobs: | |
name: vegafusion-wasm-packages | ||
path: vegafusion-wasm/pkg/vegafusion-wasm-*.tgz | ||
|
||
check-vegafusion-python: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # [email protected] | ||
- uses: prefix-dev/[email protected] | ||
with: | ||
pixi-version: v0.30.0 | ||
- name: Cache | ||
uses: actions/cache@v3 | ||
with: | ||
key: ${{ runner.os }}-${{ hashFiles('pixi.lock', 'Cargo.lock') }}-build-vegafusion-wasm | ||
path: | | ||
~/.cargo | ||
target | ||
.pixi | ||
- name: Check format and lint | ||
run: | | ||
pixi run lint-check-py | ||
- name: Type check | ||
run: | | ||
pixi run type-check-py | ||
# Use maturin action to build linux wheels within proper manylinux compatible containers | ||
# (This is why we don't use the pixi "build-py" action) | ||
build-vegafusion-python-linux-64: | ||
|
@@ -325,7 +348,7 @@ jobs: | |
- name: Setup Python | ||
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # [email protected] | ||
with: | ||
python-version: '3.8' | ||
python-version: '3.9' | ||
- name: Install Chrome | ||
uses: browser-actions/setup-chrome@f0ff752add8c926994566c80b3ceadfd03f24d12 # pin@latest | ||
with: | ||
|
@@ -345,7 +368,7 @@ jobs: | |
python -m pip install $vegafusion | ||
# Optional dependencies | ||
python -m pip install pyarrow==10.0 altair==5.1.2 polars[timezone] "duckdb>=1.0" vl-convert-python | ||
python -m pip install pyarrow==10.0 altair==5.1.2 "numpy<2" polars[timezone] "duckdb>=1.0" vl-convert-python | ||
# Test dependencies | ||
python -m pip install pytest altair vega-datasets scikit-image | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[mypy] | ||
python_version = 3.9 | ||
cache_dir = .mypy_cache | ||
strict = true | ||
files = vegafusion/ | ||
|
||
ignore_missing_imports = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
line-length = 88 | ||
indent-width = 4 | ||
include = ["vegafusion/**/*.py", "tests/**/*.py"] | ||
exclude = ["vegafusion/datasource/_dfi_types.py", "tests/altair_mocks/**/*.py"] | ||
target-version = "py39" | ||
|
||
[lint] | ||
select = [ | ||
"E", # pycodestyle Error | ||
"F", # Pyflakes | ||
"W", # pycodestyle Warning | ||
"I", # isort | ||
"N", # PEP8 Naming | ||
"UP", # pyupgrade | ||
"YTT", # flake8-2020 | ||
"ANN", # flake8-annotations | ||
"S", # flake8-bandit | ||
"BLE", # flake8-blind-except | ||
"B", # flake8-bugbear | ||
"A", # flake8-annotations-complexity | ||
"C4", # flake8-comprehensions | ||
"EM", # flake8-errmsg | ||
"FA", # flake8-future-annotations | ||
] | ||
|
||
ignore = [ | ||
# Allow assert statements | ||
"S101", | ||
|
||
# Rules that conflict with other rules | ||
"D211", # No blank lines allowed before class docstring (no-blank-line-before-class-docstring) | ||
"D213", # Multi-line docstring summary should start at the second line (multi-line-docstring-summary-start) | ||
"EM101", # Exception must not use an string literal | ||
"EM102", # Exception must not use an f-string literal | ||
|
||
# Not compatible with Python 3.9. Re-enable when upgrading to Python 3.10+ | ||
"UP007", # Using old-style union syntax (e.g., Union[int, str] instead of int | str) | ||
"UP018", # Using non-native literals (e.g., using 'int' instead of 'Literal[int]') | ||
|
||
# Deprecated and not useful | ||
"ANN101", # Missing type annotation for self in method (missing-type-annotation-for-self) | ||
"ANN102", # Missing type annotation for class (missing-type-cls) | ||
|
||
"S608", # SQL injection | ||
|
||
# Conflicting lint rules with Ruff formatter | ||
"W191", # Tab indentation | ||
"E111", # Indentation with invalid multiple | ||
"E114", # Indentation with invalid multiple comment | ||
"E117", # Over-indented | ||
"D206", # Indent with spaces | ||
"D300", # Triple single quotes | ||
"Q000", # Bad quotes inline string | ||
"Q001", # Bad quotes multiline string | ||
"Q002", # Bad quotes docstring | ||
"Q003", # Avoidable escaped quote | ||
"COM812", # Missing trailing comma | ||
"COM819", # Prohibited trailing comma | ||
"ISC001", # Single-line implicit string concatenation | ||
"ISC002", # Multi-line implicit string concatenation | ||
] | ||
|
||
[lint.per-file-ignores] | ||
# Ignore some lint checks in test directory | ||
"tests/*" = ["D", "ANN", "S", "I", "E501"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.