Repository navigation
Releases
0.0.3
Release Notes
uv add --dev "basedpython>=0.0.3"stubs
- a module with a stub is checked against it:
what the stub declares for a parameter, a return type, a module variable or a class attribute
the module leaves unannotated is its declared type in the module's own body, and
missing-runtime-member,incompatible-stub-signature,incompatible-stub-attribute,
incompatible-stub-basesandmissing-stub-memberreport where the two disagree - a stub's types are read in terms of the runtime module it describes, so a class the stub defines
is the module's class of the same name - a package with a
by.typedmarker is typed by its.byi, as its.byis already the source,
rather than by the.pyiderived from it - an editor can show a stub and its module side by side, declaration by declaration, with
by/documentCounterparts - the on-disk copy of the vendored stubs is named after their contents, so a new
byno longer
opens an older one's copy for go-to-definition
by run and by repl
by runtakes the path of
a file as well as a module name:by run app/cli.byrunsapp.cliinside its package, and
by run manage.py checkruns a.pyfile as python runs a script.by repl --moduletakes a
path with the same meaning- what the program writes into the staged tree is written back to the project: a new file, or a
changed copy of a file still holding what was staged. a file the program deleted, renamed away
or replaced is kept and reported, and nothing in__pycache__is written back --notes PATHwrites whatby runsays after the program ends toPATHas json lines, so the
program's own last line ends the output- an uncaught exception prints every exception chained to it, as python does, and its traceback
leaves out every frame ofby's own runner - the program gets the
__main__namespace python gives a script - a module
importlib.reloadcompiles after its.bywas saved over is compiled where it is
django
- a
manage.pylens
in a project with a.bysource runs throughby run, so the command sees the.bymodels and
what it writes is written back - a lens runs the
manage.pyit was offered for, so two django workspaces each run their own,
and is refused in a workspace the editor does not trust
narrowing
- a predicate
or assertion
recovered from a function's body narrows in.pyfiles too, and its hint shows the place it narrows - recovery no longer narrows through a
breakout of afinally, a non-defoverride, a
decorator, or aTypeIsabout another place
editor
- every inlay hint whose label is source carries the edit that writes it, and a tooltip where it
has more to say.by/inlayHintCataloglists every kind of hint with a live example - no completions are offered inside a number literal
other changes
- a directory below a package root holding a basedpython module is a
regular package without an
__init__.by - a type test at the end of a comparison chain,
x < 1 is int, is rejected rather than lowered to
x < False, and the linter no longer reports python's identity-comparison rules on a type test - a checked
.pyoperator dunder declares theNotImplementedit returns, as a.byone does - an override in a vendored stub takes no default from the method it overrides
Install basedpython 0.0.3
Install prebuilt binaries via shell script
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/KotlinIsland/basedpython/releases/download/0.0.3/basedpython-installer.sh | shInstall prebuilt binaries via powershell script
powershell -ExecutionPolicy Bypass -c "irm https://github.com/KotlinIsland/basedpython/releases/download/0.0.3/basedpython-installer.ps1 | iex"Download basedpython 0.0.3
Verifying GitHub Artifact Attestations
The artifacts in this release have attestations generated with GitHub Artifact Attestations. These can be verified by using the [GitHub CLI](https://cli.github.com/manual/gh_attestation_verif...
0.0.2
Release Notes
uv add --dev "basedpython>=0.0.2"operator dispatch
operator dispatch follows python's own rule:
an operation falls back past a dunder only for an operand outside its parameter's runtime domain
- a
.byoperator dunder tests its operand before its body runs, and returnsNotImplemented
outside the parameter's domain - a
.pyoperator dunder is checked against the operand python hands it: the body sees what's
outside the domain, and aNotImplementedinside the domain falls back NotImplementedis typed: a writtenNotImplementedTypereturn falls back, and.bydeclares it- an
__eq__or__ne__override may narrow its operand, or declareNotImplementedType - an operand that may share a subclass with a dunder's domain may reach it, so the operation may be
either side's answer; an exact, final or disjoint-base operand stays outside - a subclass's reflected dunder answers as its ancestor's own dunder does, and a class's
__gt__
as its own__lt__unless the class is final - a subclass's in-place dunder answers as its ancestor's binary dunder does, and an operator dunder
override takes only what the overridden dunder takes.invalid-reflected-dunderis now
invalid-operator-override
protocols
- a
protocollowers onto basedpython's own protocol base rather thantyping.Protocol;
lowering.compatibilityrestorestyping.Protocol.
runtime_checkableis reported, and the two kinds of protocol don't mix - a built package's
by.typedrecords whether it was lowered withlowering.compatibility, and a
project reads that package's protocols as it was built
other changes
- an abstract method is implemented by a class mixed in later in the mro, so
class E(D, Impl)is
implemented byImpl by initcreates the project's environment withuv sync, and themain.bytemplate no longer
callsmain()- the docs carry basedpython's logo and palette, show the python
bywrites beside the landing
page's example, and unfurl into a social card when shared
Install basedpython 0.0.2
Install prebuilt binaries via shell script
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/KotlinIsland/basedpython/releases/download/0.0.2/basedpython-installer.sh | shInstall prebuilt binaries via powershell script
powershell -ExecutionPolicy Bypass -c "irm https://github.com/KotlinIsland/basedpython/releases/download/0.0.2/basedpython-installer.ps1 | iex"Download basedpython 0.0.2
Verifying GitHub Artifact Attestations
The artifacts in this release have attestations generated with GitHub Artifact Attestations. These can be verified by using the GitHub CLI:
gh attestation verify <file-path of downloaded artifact> --repo KotlinIsland/basedpythonYou can also download the attestation from GitHub and verify against that directly:
gh attestation verify <file-path of downloaded artifact> --bundle <file-path of downloaded attestation>0.0.1
Release Notes
the first stable release of basedpython: a python-like language with sum types, extensions,
optional chaining and a type system that knows what your code means, transpiled to plain python
any python tool can read. it ships as the basedpython package, with two executables: by, the
type checker, transpiler and project driver, and buff, the linter and formatter
uv add --dev "basedpython>=0.0.1"getting started takes about five minutes. the
feature reference has a page for everything below
why try it
- plain python out the other end:
by buildwrites ordinary.pyfiles, so pytest, mypy,
ruff and the rest of your stack keep working - write for the newest python, ship for the oldest: polyfills
lower new syntax to run on the interpreters your users have - a type checker that is useful on plain python too: built on ty, with
sound types in place of gradual ones and
framework support for pydantic, sqlalchemy, pytest and
django - native speed when you want it:
by compilebuilds
the same source into CPython extension modules - tooling from day one: a language server, a formatter, a linter and an
intellij plugin
the language
.by keeps almost all of python's meaning; differences from python
lists every place it does not
- data and variants:
enum classsum types with payloads,
sealed classes with exhaustivematch, and
sentineldeclarations - expressions: optional chaining (
?.),
none-coalesce (??),
statement expressions
(x = match y:), destructuring and
if let,
trailing lambda blocks, and
checked casts - declarations: modifiers and visibility,
block scoping,
properties that read like declarations, an
init method shorthand, and a
mainfunction whose parameters are its command
line - extending what exists: extensions add members to
an existing type and declare its conformance to a protocol, and
conversions (__from__,__into__,__of__) say
how one type becomes another - effects: exception tracking (
raises),
local lifetimes (local,once) and
context parameters - imports and resources: lazy imports,
from x export yand
static resources
(import "config.yaml" as config)
the type system
- types that say more: intersections,
negations, tuple
and callable type literals,
typed dict literals,
template literal types and
inline protocols - computation in types: match types,
type deftype functions and
symbolic arithmetic in type parameters - generics: bound ranges,
type mappings,
safe variance, and type parameters that survive
to runtime through reified generics - inference that narrows instead of shrugging: sound types,
precise unsolved type variables,
inherited parameter types and
narrowing predicates - checks that work on
.pyas well: regex group types,
boolean conditions,
refutable unpacking,
unused return values and
string formatting - a more honest standard library: typeshed improvements
such as covariant mapping keys and precisefunctools.cache - two presets:
strictandty-compatible, chosen with
type-checking-preset
transpiling and running
by buildtranspiles a project to python, and
by runtranspiles and runs a module in one step- runtime soundness checks guard each place an unchecked
value enters a typed slot by replis an interactive session in basedpython, and
debugging stops and steps at.bylinesby transpile --reverse
rewrites existing python into basedpython
native compilation
by compile builds modules into native CPython
extension modules for python 3.11 to 3.14, including the free-threaded builds. a function it cannot
compile keeps its interpreted definition, and --verbose says which and why
editors
- the language server gives completions, inlay hints, hover,
an outline and refactorings such as moving a
definition, extracting a superclass and changing a signature - the intellij plugin makes
.bya first-class
language in PyCharm and IntelliJ IDEA, withby,buffand the debugger bundled by checkanswers from a running language server's
warm state when there is onebufflints and formats.bywith ruff's rules plus the
BYrules, and aligns consecutive assignments
frameworks
pydantic, sqlalchemy,
pytest and django
are modelled directly, so synthesized constructors, mapped columns and injected fixtures check like
ordinary code. the language server also understands
django templates, and
basedpython-ui is a compose-style ui library the
...
0.0.1-b2
Download basedpython 0.0.1-b2
Verifying GitHub Artifact Attestations
The artifacts in this release have attestations generated with GitHub Artifact Attestations. These can be verified by using the GitHub CLI:
gh attestation verify <file-path of downloaded artifact> --repo KotlinIsland/basedpythonYou can also download the attestation from GitHub and verify against that directly:
gh attestation verify <file-path of downloaded artifact> --bundle <file-path of downloaded attestation>0.0.1-b1
Download basedpython 0.0.1-b1
Verifying GitHub Artifact Attestations
The artifacts in this release have attestations generated with GitHub Artifact Attestations. These can be verified by using the GitHub CLI:
gh attestation verify <file-path of downloaded artifact> --repo KotlinIsland/basedpythonYou can also download the attestation from GitHub and verify against that directly:
gh attestation verify <file-path of downloaded artifact> --bundle <file-path of downloaded attestation>0.0.1-a9
literalandfinaltype modifierssomemodifierlet .. elsereifiedtype parameter keyword- destructured parameters
- unique loop bindings
- safe variance of private members
class A[T]: private t: T def f(self): A().t = 1 # should be an error, unless T is invariant def f(self: A[object]): self.t = "a" # should be an error, can only assign T - solve type var as
Never - f-string and str checks
- inferred functions
- warn when using a bool as an int
- boolean condition overlap diagnostic
- assignment alignment formatting
- type mapping syntax:
[T in (int, str)] - django template file support
from X export Y->from X import Y as Y- redundant
-> Nonediagnostic - bad
cast/isdiagnostic
Download basedpython 0.0.1-a9
Verifying GitHub Artifact Attestations
The artifacts in this release have attestations generated with GitHub Artifact Attestations. These can be verified by using the GitHub CLI:
gh attestation verify <file-path of downloaded artifact> --repo KotlinIsland/basedpythonYou can also download the attestation from GitHub and verify against that directly:
gh attestation verify <file-path of downloaded artifact> --bundle <file-path of downloaded attestation>0.0.1-a8
Download basedpython 0.0.1-a8
Verifying GitHub Artifact Attestations
The artifacts in this release have attestations generated with GitHub Artifact Attestations. These can be verified by using the GitHub CLI:
gh attestation verify <file-path of downloaded artifact> --repo KotlinIsland/basedpythonYou can also download the attestation from GitHub and verify against that directly:
gh attestation verify <file-path of downloaded artifact> --bundle <file-path of downloaded attestation>0.0.1-a7
- properties
Self/TypedDictas a bound- protocol notation
- asserting type guards
- enhanced type is
- regex group types
- receiver types
implementationstype defs- type ranges/lower bounds
- exception tracking
Download basedpython 0.0.1-a7
Verifying GitHub Artifact Attestations
The artifacts in this release have attestations generated with GitHub Artifact Attestations. These can be verified by using the GitHub CLI:
gh attestation verify <file-path of downloaded artifact> --repo KotlinIsland/basedpythonYou can also download the attestation from GitHub and verify against that directly:
gh attestation verify <file-path of downloaded artifact> --bundle <file-path of downloaded attestation>0.0.1-a6
- typeshed:
- fix
functool.cache - [
frozen]dict/setupper bound ofHashable ContextManagerabstract__enter__
- fix
UnsafeUniontype- generic type operations
- keyword type parameters
- main function args
- annotation reification
Download basedpython 0.0.1-a6
Verifying GitHub Artifact Attestations
The artifacts in this release have attestations generated with GitHub Artifact Attestations. These can be verified by using the GitHub CLI:
gh attestation verify <file-path of downloaded artifact> --repo KotlinIsland/basedpythonYou can also download the attestation from GitHub and verify against that directly:
gh attestation verify <file-path of downloaded artifact> --bundle <file-path of downloaded attestation>0.0.1-a5
extensionsCharactertypes- simple trailing lambdas
local/onceparameter modifierscontextparameters- django/sqlalchemy/pydantic/pytest support
Download basedpython 0.0.1-a5
Verifying GitHub Artifact Attestations
The artifacts in this release have attestations generated with GitHub Artifact Attestations. These can be verified by using the GitHub CLI:
gh attestation verify <file-path of downloaded artifact> --repo KotlinIsland/basedpythonYou can also download the attestation from GitHub and verify against that directly:
gh attestation verify <file-path of downloaded artifact> --bundle <file-path of downloaded attestation>