basedpython 0.0.1a3__py3-none-win_amd64.whl → 0.0.1a4__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {basedpython-0.0.1a3.data → basedpython-0.0.1a4.data}/scripts/buff.exe +0 -0
- {basedpython-0.0.1a3.data → basedpython-0.0.1a4.data}/scripts/by.exe +0 -0
- basedpython-0.0.1a4.dist-info/METADATA +85 -0
- basedpython-0.0.1a4.dist-info/RECORD +7 -0
- {basedpython-0.0.1a3.dist-info → basedpython-0.0.1a4.dist-info}/sboms/basedpython.cyclonedx.json +12 -12
- basedpython-0.0.1a3.dist-info/METADATA +0 -384
- basedpython-0.0.1a3.dist-info/RECORD +0 -7
- {basedpython-0.0.1a3.dist-info → basedpython-0.0.1a4.dist-info}/WHEEL +0 -0
- {basedpython-0.0.1a3.dist-info → basedpython-0.0.1a4.dist-info}/licenses/LICENSE +0 -0
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: basedpython
|
|
3
|
+
Version: 0.0.1a4
|
|
4
|
+
Classifier: Development Status :: 1 - Planning
|
|
5
|
+
Classifier: Environment :: Console
|
|
6
|
+
Classifier: Intended Audience :: Developers
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Classifier: Programming Language :: Python
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Rust
|
|
19
|
+
Classifier: Topic :: Software Development
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
22
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
23
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
24
|
+
Classifier: Topic :: Software Development :: Pre-processors
|
|
25
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Summary: a transpiler for both Python and basedpython
|
|
28
|
+
Keywords: automation,flake8,pycodestyle,pyflakes,pylint,clippy
|
|
29
|
+
Author-email: "Astral Software Inc." <hey@astral.sh>
|
|
30
|
+
License-Expression: MIT
|
|
31
|
+
Requires-Python: >=3.7
|
|
32
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
33
|
+
Project-URL: Changelog, https://github.com/KotlinIsland/basedpython/blob/main/CHANGELOG.md
|
|
34
|
+
Project-URL: Documentation, https://kotlinisland.github.io/basedpython/
|
|
35
|
+
Project-URL: Repository, https://github.com/KotlinIsland/basedpython
|
|
36
|
+
|
|
37
|
+
# basedpython
|
|
38
|
+
|
|
39
|
+
a python type checker and a python-like language that transpiles to pure python
|
|
40
|
+
|
|
41
|
+
```by
|
|
42
|
+
enum class Shape:
|
|
43
|
+
case Circle(radius: int)
|
|
44
|
+
case Rect(width: int, height: int)
|
|
45
|
+
|
|
46
|
+
def area(self) -> int:
|
|
47
|
+
match self:
|
|
48
|
+
case Shape.Circle(r): return 3 * r * r
|
|
49
|
+
case Shape.Rect(w, h): return w * h
|
|
50
|
+
|
|
51
|
+
extension list[Element: Shape]:
|
|
52
|
+
def first_circle(self) -> Shape.Circle?:
|
|
53
|
+
for shape in self:
|
|
54
|
+
if shape is Shape.Circle:
|
|
55
|
+
return shape
|
|
56
|
+
return None
|
|
57
|
+
|
|
58
|
+
def stats(shapes: list[Shape]) -> (count: int, total: int):
|
|
59
|
+
return (len(shapes), sum(s.area() for s in shapes))
|
|
60
|
+
|
|
61
|
+
def main():
|
|
62
|
+
let shapes = [Shape.Circle(1), Shape.Rect(2, 3)]
|
|
63
|
+
let summary = stats(shapes)
|
|
64
|
+
print(f"{summary.count} shapes, {summary.total} total")
|
|
65
|
+
print(shapes.first_circle()?.radius ?? 0)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## installation
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
uv add --dev basedpython
|
|
72
|
+
by run main
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## documentation
|
|
76
|
+
|
|
77
|
+
[kotlinisland.github.io/basedpython](https://kotlinisland.github.io/basedpython/)
|
|
78
|
+
|
|
79
|
+
## acknowledgements
|
|
80
|
+
|
|
81
|
+
basedpython is a fork of [astral-sh/ruff](https://github.com/astral-sh/ruff) —
|
|
82
|
+
it reuses ruff's parser, AST, and fix-application machinery, and the type
|
|
83
|
+
checker is built on [ty](https://github.com/astral-sh/ty). none of this would
|
|
84
|
+
exist without the work of the astral team and the wider ruff community
|
|
85
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
basedpython-0.0.1a4.data/scripts/buff.exe,sha256=JtBO3ICv270sN8rsDcMqpDmdNhxOPc7FacMUqQLHpP4,34799616
|
|
2
|
+
basedpython-0.0.1a4.data/scripts/by.exe,sha256=gEaG3ja20cAXwDSMJ2TcAmogDdjs3jtXQY2SG3fAYcs,33101824
|
|
3
|
+
basedpython-0.0.1a4.dist-info/METADATA,sha256=K3m5iu80MXIr16zEeg35q8hLm3Uabu9DWK9BodMK94A,3119
|
|
4
|
+
basedpython-0.0.1a4.dist-info/WHEEL,sha256=2zDlIYIdD4m4N3p5DVEG3iJhGLdhsBQgdH-FqVkAur8,94
|
|
5
|
+
basedpython-0.0.1a4.dist-info/licenses/LICENSE,sha256=JZfYVBIrd93HGXFWTKI1CjdghXXOMkrcVlCisgUcjxg,20731
|
|
6
|
+
basedpython-0.0.1a4.dist-info/sboms/basedpython.cyclonedx.json,sha256=qBmSpkeOksPNuerYJrbw1IDt5Kagjw8WPHfXcLfgvQY,432915
|
|
7
|
+
basedpython-0.0.1a4.dist-info/RECORD,,
|
{basedpython-0.0.1a3.dist-info → basedpython-0.0.1a4.dist-info}/sboms/basedpython.cyclonedx.json
RENAMED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"bomFormat": "CycloneDX",
|
|
3
3
|
"specVersion": "1.5",
|
|
4
4
|
"version": 1,
|
|
5
|
-
"serialNumber": "urn:uuid:
|
|
5
|
+
"serialNumber": "urn:uuid:7b538d48-c1bd-4306-b8d2-89f10a231028",
|
|
6
6
|
"metadata": {
|
|
7
|
-
"timestamp": "2026-07-
|
|
7
|
+
"timestamp": "2026-07-19T10:10:22.521589300Z",
|
|
8
8
|
"tools": [
|
|
9
9
|
{
|
|
10
10
|
"vendor": "CycloneDX",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
],
|
|
15
15
|
"component": {
|
|
16
16
|
"type": "application",
|
|
17
|
-
"bom-ref": "path+file:///D:/a/basedpython/basedpython/crates/basedpython#0.0.1-
|
|
17
|
+
"bom-ref": "path+file:///D:/a/basedpython/basedpython/crates/basedpython#0.0.1-a4",
|
|
18
18
|
"name": "basedpython",
|
|
19
|
-
"version": "0.0.1-
|
|
19
|
+
"version": "0.0.1-a4",
|
|
20
20
|
"description": "the basedpython toolchain — the `by` type-checker / transpiler and `buff` linter / formatter",
|
|
21
21
|
"scope": "required",
|
|
22
22
|
"licenses": [
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"expression": "MIT"
|
|
25
25
|
}
|
|
26
26
|
],
|
|
27
|
-
"purl": "pkg:cargo/basedpython@0.0.1-
|
|
27
|
+
"purl": "pkg:cargo/basedpython@0.0.1-a4?download_url=file://.",
|
|
28
28
|
"externalReferences": [
|
|
29
29
|
{
|
|
30
30
|
"type": "vcs",
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"components": [
|
|
35
35
|
{
|
|
36
36
|
"type": "application",
|
|
37
|
-
"bom-ref": "path+file:///D:/a/basedpython/basedpython/crates/basedpython#0.0.1-
|
|
37
|
+
"bom-ref": "path+file:///D:/a/basedpython/basedpython/crates/basedpython#0.0.1-a4 bin-target-0",
|
|
38
38
|
"name": "buff",
|
|
39
|
-
"version": "0.0.1-
|
|
40
|
-
"purl": "pkg:cargo/basedpython@0.0.1-
|
|
39
|
+
"version": "0.0.1-a4",
|
|
40
|
+
"purl": "pkg:cargo/basedpython@0.0.1-a4?download_url=file://.#src/buff.rs"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
"type": "application",
|
|
44
|
-
"bom-ref": "path+file:///D:/a/basedpython/basedpython/crates/basedpython#0.0.1-
|
|
44
|
+
"bom-ref": "path+file:///D:/a/basedpython/basedpython/crates/basedpython#0.0.1-a4 bin-target-1",
|
|
45
45
|
"name": "by",
|
|
46
|
-
"version": "0.0.1-
|
|
47
|
-
"purl": "pkg:cargo/basedpython@0.0.1-
|
|
46
|
+
"version": "0.0.1-a4",
|
|
47
|
+
"purl": "pkg:cargo/basedpython@0.0.1-a4?download_url=file://.#src/by.rs"
|
|
48
48
|
}
|
|
49
49
|
]
|
|
50
50
|
},
|
|
@@ -10233,7 +10233,7 @@
|
|
|
10233
10233
|
],
|
|
10234
10234
|
"dependencies": [
|
|
10235
10235
|
{
|
|
10236
|
-
"ref": "path+file:///D:/a/basedpython/basedpython/crates/basedpython#0.0.1-
|
|
10236
|
+
"ref": "path+file:///D:/a/basedpython/basedpython/crates/basedpython#0.0.1-a4",
|
|
10237
10237
|
"dependsOn": [
|
|
10238
10238
|
"registry+https://github.com/rust-lang/crates.io-index#anyhow@1.0.102",
|
|
10239
10239
|
"registry+https://github.com/rust-lang/crates.io-index#argfile@1.0.0",
|
|
@@ -1,384 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: basedpython
|
|
3
|
-
Version: 0.0.1a3
|
|
4
|
-
Classifier: Development Status :: 1 - Planning
|
|
5
|
-
Classifier: Environment :: Console
|
|
6
|
-
Classifier: Intended Audience :: Developers
|
|
7
|
-
Classifier: Operating System :: OS Independent
|
|
8
|
-
Classifier: Programming Language :: Python
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
-
Classifier: Programming Language :: Rust
|
|
19
|
-
Classifier: Topic :: Software Development
|
|
20
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
-
Classifier: Topic :: Software Development :: Quality Assurance
|
|
22
|
-
Classifier: Topic :: Software Development :: Compilers
|
|
23
|
-
Classifier: Topic :: Software Development :: Build Tools
|
|
24
|
-
Classifier: Topic :: Software Development :: Pre-processors
|
|
25
|
-
Classifier: Topic :: Software Development :: Code Generators
|
|
26
|
-
License-File: LICENSE
|
|
27
|
-
Summary: a transpiler for both Python and basedpython
|
|
28
|
-
Keywords: automation,flake8,pycodestyle,pyflakes,pylint,clippy
|
|
29
|
-
Author-email: "Astral Software Inc." <hey@astral.sh>
|
|
30
|
-
License-Expression: MIT
|
|
31
|
-
Requires-Python: >=3.7
|
|
32
|
-
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
33
|
-
Project-URL: Changelog, https://github.com/KotlinIsland/basedpython/blob/main/CHANGELOG.md
|
|
34
|
-
Project-URL: Documentation, https://kotlinisland.github.io/basedpython/
|
|
35
|
-
Project-URL: Repository, https://github.com/KotlinIsland/basedpython
|
|
36
|
-
|
|
37
|
-
# basedpython
|
|
38
|
-
|
|
39
|
-
a Python-like language that transpiles to pure Python
|
|
40
|
-
|
|
41
|
-
## acknowledgements
|
|
42
|
-
|
|
43
|
-
basedpython is a fork of [astral-sh/ruff](https://github.com/astral-sh/ruff). the
|
|
44
|
-
transpiler reuses ruff's parser (`ruff_python_parser`), AST (`ruff_python_ast`),
|
|
45
|
-
and fix-application machinery (`ruff_diagnostics::Edit`/`Fix`), and the type
|
|
46
|
-
checker is built on [ty](https://github.com/astral-sh/ty). none of this would
|
|
47
|
-
exist without the work of the astral team and the wider ruff community
|
|
48
|
-
|
|
49
|
-
## installation
|
|
50
|
-
|
|
51
|
-
```shell
|
|
52
|
-
uv add --dev basedpython
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## usage
|
|
56
|
-
|
|
57
|
-
```shell
|
|
58
|
-
# run a module
|
|
59
|
-
by run main
|
|
60
|
-
|
|
61
|
-
# build all .by files to out/
|
|
62
|
-
by build
|
|
63
|
-
|
|
64
|
-
# low-level: transpile a single file to stdout
|
|
65
|
-
by transpile file.by
|
|
66
|
-
echo 'x[(a, b)]' | by transpile
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## options
|
|
70
|
-
|
|
71
|
-
```shell
|
|
72
|
-
# target a minimum Python version (default: 3.10)
|
|
73
|
-
by --min-version 3.11 run main
|
|
74
|
-
by --min-version 3.12 build
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## features
|
|
78
|
-
|
|
79
|
-
### anonymous named tuple syntax
|
|
80
|
-
|
|
81
|
-
write a structural record inline, no separate `class` or `NamedTuple` import.
|
|
82
|
-
identical shapes anywhere in the module collapse to a single hoisted
|
|
83
|
-
`typing.NamedTuple` subclass, so structural equality is preserved at the type
|
|
84
|
-
level:
|
|
85
|
-
|
|
86
|
-
```bython
|
|
87
|
-
def user(x: (name: str, age: int)) -> (name: str, age: int):
|
|
88
|
-
return ("charlie", 36)
|
|
89
|
-
|
|
90
|
-
a = (name: str, age: int)
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
mixed positional/named shapes are allowed
|
|
94
|
-
|
|
95
|
-
### mutable default argument via lazy evaluation
|
|
96
|
-
|
|
97
|
-
mutable default arguments are automatically rewritten to the sentinel pattern:
|
|
98
|
-
|
|
99
|
-
```python
|
|
100
|
-
# input
|
|
101
|
-
def f(x=[], y={}):
|
|
102
|
-
pass
|
|
103
|
-
|
|
104
|
-
# output
|
|
105
|
-
_MISSING = object()
|
|
106
|
-
def f(x=_MISSING, y=_MISSING):
|
|
107
|
-
if x is _MISSING:
|
|
108
|
-
x = []
|
|
109
|
-
if y is _MISSING:
|
|
110
|
-
y = {}
|
|
111
|
-
pass
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### callable syntax
|
|
115
|
-
|
|
116
|
-
write callable types with arrow syntax. denotable shapes transpile to
|
|
117
|
-
`typing.Callable`; non-denotable shapes (named params, `/` / `*` markers,
|
|
118
|
-
variadics, kwargs) synthesize a hoisted `typing.Protocol` with `__call__`:
|
|
119
|
-
|
|
120
|
-
```bython
|
|
121
|
-
# input
|
|
122
|
-
f: (int, str) -> bool
|
|
123
|
-
g: () -> None
|
|
124
|
-
h: (a: int, *args: str) -> bool
|
|
125
|
-
|
|
126
|
-
# output
|
|
127
|
-
from typing import Callable, Protocol
|
|
128
|
-
f: Callable[[int, str], bool]
|
|
129
|
-
g: Callable[[], None]
|
|
130
|
-
|
|
131
|
-
class _Callable_abcde(Protocol):
|
|
132
|
-
def __call__(self, a: int, /, *args: str) -> bool: ...
|
|
133
|
-
|
|
134
|
-
h: _Callable_abcde
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
identical non-denotable shapes anywhere in the module collapse to a single
|
|
138
|
-
synthesized protocol. nested arrows (`(int) -> (str) -> bool`) nest the
|
|
139
|
-
`Callable`s
|
|
140
|
-
|
|
141
|
-
### python version polyfills
|
|
142
|
-
|
|
143
|
-
basedpython lets you write code in modern python syntax and run it on older
|
|
144
|
-
interpreters. when `--min-version` is below the version that first introduced a
|
|
145
|
-
feature, the transpiler rewrites that feature into an equivalent shape that
|
|
146
|
-
runs on the target interpreter — a "polyfill". if the target already has the
|
|
147
|
-
feature natively, the polyfill is a no-op and the source survives unchanged
|
|
148
|
-
|
|
149
|
-
a few rules hold for every polyfill:
|
|
150
|
-
|
|
151
|
-
- **opt-in by target** — only triggered when `--min-version` is below the
|
|
152
|
-
feature's introduction version. raise the floor to drop the rewrite
|
|
153
|
-
- **shape-preserving** — the rewritten code has the same runtime semantics and,
|
|
154
|
-
where reasonable, the same static-typing behaviour as the original
|
|
155
|
-
- **no runtime dependency on basedpython** — output is plain python; the
|
|
156
|
-
generated code does not call back into a basedpython runtime
|
|
157
|
-
|
|
158
|
-
**PEP 695 generics** (3.12 → 3.10):
|
|
159
|
-
|
|
160
|
-
```python
|
|
161
|
-
# input
|
|
162
|
-
class Stack[T]:
|
|
163
|
-
items: list[T]
|
|
164
|
-
|
|
165
|
-
def identity[T](x: T) -> T:
|
|
166
|
-
return x
|
|
167
|
-
|
|
168
|
-
type Vector = list[float]
|
|
169
|
-
|
|
170
|
-
# output
|
|
171
|
-
from typing import TypeVar, Generic, TypeAlias
|
|
172
|
-
_T = TypeVar("_T")
|
|
173
|
-
class Stack(Generic[_T]):
|
|
174
|
-
items: list[_T]
|
|
175
|
-
|
|
176
|
-
_T = TypeVar("_T")
|
|
177
|
-
def identity(x: _T) -> _T:
|
|
178
|
-
return x
|
|
179
|
-
|
|
180
|
-
Vector: TypeAlias = list[float]
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**`typing` import redirect** — names not available in stdlib until a later version are automatically redirected to `typing_extensions`:
|
|
184
|
-
|
|
185
|
-
```python
|
|
186
|
-
# input (targeting 3.10)
|
|
187
|
-
from typing import Self, Never, override
|
|
188
|
-
|
|
189
|
-
# output
|
|
190
|
-
from typing_extensions import Self, Never, override
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
**expression rewrites** (targeting < 3.11):
|
|
194
|
-
|
|
195
|
-
```python
|
|
196
|
-
datetime.UTC → datetime.timezone.utc
|
|
197
|
-
sys.exception() → sys.exc_info()[1]
|
|
198
|
-
math.exp2(x) → 2 ** (x)
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### multiline strings
|
|
202
|
-
|
|
203
|
-
triple-quoted strings opening with `"""\n` and consistent leading indentation
|
|
204
|
-
get their common indent stripped at compile time. no `textwrap.dedent` import,
|
|
205
|
-
no runtime cost:
|
|
206
|
-
|
|
207
|
-
```python
|
|
208
|
-
# input
|
|
209
|
-
text = """
|
|
210
|
-
hello
|
|
211
|
-
world
|
|
212
|
-
"""
|
|
213
|
-
|
|
214
|
-
# output
|
|
215
|
-
text = """\
|
|
216
|
-
hello
|
|
217
|
-
world\
|
|
218
|
-
"""
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
### None operators
|
|
222
|
-
|
|
223
|
-
#### `?.` — optional attribute access
|
|
224
|
-
|
|
225
|
-
`a?.b` short-circuits to `None` when `a` is `None`. chains use a walrus to
|
|
226
|
-
avoid evaluating compound prefixes twice:
|
|
227
|
-
|
|
228
|
-
```bython
|
|
229
|
-
# input
|
|
230
|
-
x = user?.profile?.name
|
|
231
|
-
|
|
232
|
-
# output
|
|
233
|
-
x = None if user is None else None if (_t := user.profile) is None else _t.name
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
#### `??` — None-coalesce
|
|
237
|
-
|
|
238
|
-
`a ?? b` returns `a` when non-`None`, otherwise `b`:
|
|
239
|
-
|
|
240
|
-
```bython
|
|
241
|
-
# input
|
|
242
|
-
x = a ?? b
|
|
243
|
-
|
|
244
|
-
# output
|
|
245
|
-
x = a if a is not None else b
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
composes with `?.` — the expanded chain is shared via a walrus so the prefix
|
|
249
|
-
runs once:
|
|
250
|
-
|
|
251
|
-
```bython
|
|
252
|
-
# input
|
|
253
|
-
y = a?.a.b ?? 1
|
|
254
|
-
|
|
255
|
-
# output
|
|
256
|
-
y = _t if (_t := None if a is None else a.a.b) is not None else 1
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
### modifier keywords
|
|
260
|
-
|
|
261
|
-
basedpython exposes the common decorator-driven idioms as bare keywords so
|
|
262
|
-
declarations stay readable. each keyword lowers to the equivalent decorator,
|
|
263
|
-
base class, or annotation and the matching import is added automatically:
|
|
264
|
-
|
|
265
|
-
| keyword (input) | output |
|
|
266
|
-
| -------------------------- | -------------------------------------------- |
|
|
267
|
-
| `final class A` | `@final` on `class A` |
|
|
268
|
-
| `final def f()` | `@final` on `def f()` |
|
|
269
|
-
| `override def f()` | `@override` on `def f()` |
|
|
270
|
-
| `abstract def f()` | `@abstractmethod` on `def f()` |
|
|
271
|
-
| `static def f()` | `@staticmethod` on `def f()` |
|
|
272
|
-
| `class def f()` | `@classmethod` on `def f()` |
|
|
273
|
-
| `data class A` | `@dataclass(slots=True)` on `A` |
|
|
274
|
-
| `frozen data class A` | `@dataclass(frozen=True, slots=True)` on `A` |
|
|
275
|
-
| `enum class B` | `class B(Enum)` |
|
|
276
|
-
| `protocol Foo` | `class Foo(Protocol)` |
|
|
277
|
-
| `let x = 5` | `x: Final = 5` |
|
|
278
|
-
| `class a = 1` (class body) | `a: ClassVar = 1` |
|
|
279
|
-
| `newtype MyInt = int` | `MyInt = NewType("MyInt", int)` |
|
|
280
|
-
|
|
281
|
-
modifiers stack — `final data class A` and `override final def f()` both work.
|
|
282
|
-
example:
|
|
283
|
-
|
|
284
|
-
```bython
|
|
285
|
-
# input
|
|
286
|
-
final data class A:
|
|
287
|
-
let x = 1
|
|
288
|
-
class y = 2
|
|
289
|
-
|
|
290
|
-
override def render(self): ...
|
|
291
|
-
class def from_str(cls, s): ...
|
|
292
|
-
static def helper(): ...
|
|
293
|
-
|
|
294
|
-
protocol Drawable:
|
|
295
|
-
def draw(self): ...
|
|
296
|
-
|
|
297
|
-
enum class Color:
|
|
298
|
-
RED = 1
|
|
299
|
-
GREEN = 2
|
|
300
|
-
|
|
301
|
-
newtype UserId = int
|
|
302
|
-
|
|
303
|
-
# output
|
|
304
|
-
from abc import abstractmethod
|
|
305
|
-
from dataclasses import dataclass
|
|
306
|
-
from enum import Enum
|
|
307
|
-
from typing import ClassVar, Final, NewType, Protocol, final
|
|
308
|
-
|
|
309
|
-
@final
|
|
310
|
-
@dataclass(slots=True)
|
|
311
|
-
class A:
|
|
312
|
-
x: Final = 1
|
|
313
|
-
y: ClassVar = 2
|
|
314
|
-
|
|
315
|
-
@override
|
|
316
|
-
def render(self): ...
|
|
317
|
-
@classmethod
|
|
318
|
-
def from_str(cls, s): ...
|
|
319
|
-
@staticmethod
|
|
320
|
-
def helper(): ...
|
|
321
|
-
|
|
322
|
-
class Drawable(Protocol):
|
|
323
|
-
def draw(self): ...
|
|
324
|
-
|
|
325
|
-
class Color(Enum):
|
|
326
|
-
RED = 1
|
|
327
|
-
GREEN = 2
|
|
328
|
-
|
|
329
|
-
UserId = NewType("UserId", int)
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
### visibility modifiers
|
|
333
|
-
|
|
334
|
-
`public` and `private` mark `def` and `class` declarations.
|
|
335
|
-
behaviour depends on whether the declaration is at module scope or inside a
|
|
336
|
-
class body:
|
|
337
|
-
|
|
338
|
-
```bython
|
|
339
|
-
# input
|
|
340
|
-
public def api(): ...
|
|
341
|
-
private def helper(): ...
|
|
342
|
-
def untouched(): ...
|
|
343
|
-
|
|
344
|
-
# output
|
|
345
|
-
def api(): ...
|
|
346
|
-
def _helper(): ...
|
|
347
|
-
def untouched(): ...
|
|
348
|
-
__all__ = ["api"]
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
- `public` at module scope — modifier stripped, name appended to an
|
|
352
|
-
auto-generated `__all__`
|
|
353
|
-
- `private` at module scope — modifier stripped, declaration renamed with a
|
|
354
|
-
leading `_` (the conventional python "internal" marker)
|
|
355
|
-
- `private` inside a class body — declaration renamed with a leading `__` so
|
|
356
|
-
python's name-mangling hides it from subclass scope
|
|
357
|
-
- `public` inside a class body — modifier stripped, no rename, no
|
|
358
|
-
`__all__` impact
|
|
359
|
-
|
|
360
|
-
### api lock file
|
|
361
|
-
|
|
362
|
-
`by generate-api-file` walks every module and emits a deterministic,
|
|
363
|
-
line-oriented summary of the project's public type-level surface to `api.lock`
|
|
364
|
-
|
|
365
|
-
the file is meant to be **diffed, not parsed**. any meaningful change to a
|
|
366
|
-
public symbol — a new parameter, a widened return type, a renamed class,
|
|
367
|
-
a removed attribute — surfaces as a line-level diff in code review
|
|
368
|
-
|
|
369
|
-
usage:
|
|
370
|
-
|
|
371
|
-
```shell
|
|
372
|
-
# write api.lock at the project root
|
|
373
|
-
by generate-api-file
|
|
374
|
-
|
|
375
|
-
# pick a path
|
|
376
|
-
by generate-api-file -o public.lock
|
|
377
|
-
|
|
378
|
-
# print to stdout (useful in CI to compare against committed lockfile)
|
|
379
|
-
by generate-api-file --stdout
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
commit `api.lock` and treat any unexpected diff in a PR as a public-api
|
|
383
|
-
breakage signal
|
|
384
|
-
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
basedpython-0.0.1a3.data/scripts/buff.exe,sha256=GcAcY4TRkOZgaM2A40Bc1b7lfiHH0qY8qNjK9emyl3I,34783744
|
|
2
|
-
basedpython-0.0.1a3.data/scripts/by.exe,sha256=qhVEvqSo6JeMhKRMfLwPVSRWGe4sCHk5MFcM7NBeaA8,32689664
|
|
3
|
-
basedpython-0.0.1a3.dist-info/METADATA,sha256=c08hWqPV-4cH94yg0l1O9jWq7FVKDIgC4HDMkeUsYSI,10969
|
|
4
|
-
basedpython-0.0.1a3.dist-info/WHEEL,sha256=2zDlIYIdD4m4N3p5DVEG3iJhGLdhsBQgdH-FqVkAur8,94
|
|
5
|
-
basedpython-0.0.1a3.dist-info/licenses/LICENSE,sha256=JZfYVBIrd93HGXFWTKI1CjdghXXOMkrcVlCisgUcjxg,20731
|
|
6
|
-
basedpython-0.0.1a3.dist-info/sboms/basedpython.cyclonedx.json,sha256=8B3KiPpQKBlS_VGNlugBdsw16sCB06OQ5GH6othm9b8,432915
|
|
7
|
-
basedpython-0.0.1a3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|