This release is a pre-release and may not be stable for production use.
TypeSpark
Bringing classes to PySpark DataFrames, built on attrs.
Declare a DataFrame like a dataclass: each attribute is a typed column. Wrap a Spark
DataFrame in the class and you get autocomplete, checked column access and transforms your type
checker can verify, with no .alias() boilerplate. Every operation calls PySpark
directly, so Spark runs exactly the code you'd have written.
import typespark as ts
import typespark.functions as tsf
class Person(ts.DataFrame):
name: ts.String
age: ts.Int
class Adult(ts.DataFrame):
full_name: ts.String
can_vote: ts.Bool
def adults(people: Person) -> Adult:
return Adult(
people,
full_name=tsf.initcap(people.name), # a typed String
can_vote=people.age >= 18, # aliased to "can_vote"
)
- Familiar syntax. If you've written a dataclass or an attrs class, you can write a
model: annotations, defaults,
field(...), inheritance. - Typed functions.
typespark.functionsmirrorspyspark.sql.functionswith typed arguments and results:tsf.upperon a number, or a misspelled unit intsf.date_trunc, is a type error instead of a silent cast ornull. - Columns are symbols, not strings. Go to definition, find references and rename work
on
people.agelike on any Python attribute. - Mistakes show up in your editor. A misspelled column, a missing output column or a wrong type is a type error, not a failure when Spark runs.
- No
.alias(). Each keyword is aliased to its column name, andadultsreturns a typedAdult, not a bareDataFrame. - One schema. The class types your code and generates the
StructTypefor your tables.
Installation
pip install "typespark[pyspark]" # with PySpark
pip install typespark # PySpark already provided by your environment
Python 3.12+, PySpark 3.5 to 4.3. Type checking with pyright (Pylance) or mypy.
TypeSpark 2.0 is in pre-release: add --pre to install it. Without it, pip installs 1.x.
Documentation
- Why TypeSpark: side by side with plain PySpark
- Concepts: models, columns, transforms, aggregates, ...
- Migrating from 1.x
- Contributing
License
Metadata
Release files for typespark 2.0.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| typespark-2.0.0a1.tar.gz | 85.9 kB | With provenance | Details for typespark-2.0.0a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| typespark-2.0.0a1-py3-none-any.whl | Python 3 | none | any | Details for typespark-2.0.0a1-py3-none-any.whl |
Total release size: 142.8 kB
Release files / typespark-2.0.0a1.tar.gz
| Download URL | typespark-2.0.0a1.tar.gz |
|---|---|
| Size | 85.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bae013b5dbe3a792132165d84357d2d751bb208adea70c32cb2420ed02382742
|
|
BLAKE2b-256 checksum How to use checksums |
7a3a5ffa65745c9c00f018d4c0e5f08d3e438bb209380aad0119b7cbcf3ca82b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / typespark-2.0.0a1-py3-none-any.whl
| Download URL | typespark-2.0.0a1-py3-none-any.whl |
|---|---|
| Size | 56.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0bce5b4a45a58860989765a0d875bb0511521a590f27d1022496e8377fb0130e
|
|
BLAKE2b-256 checksum How to use checksums |
b5085833b6a6b18f5d36a332e1ee9aa5d8b1b0a7aad45b58b489bbadd2eba945
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for typespark 2.0.0a1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for typespark-2.0.0a1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.