basedpython 0.0.1a3__py3-none-win32.whl → 0.0.1a5__py3-none-win32.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.1a5.data}/scripts/buff.exe +0 -0
- {basedpython-0.0.1a3.data → basedpython-0.0.1a5.data}/scripts/by.exe +0 -0
- basedpython-0.0.1a5.dist-info/METADATA +85 -0
- basedpython-0.0.1a5.dist-info/RECORD +7 -0
- {basedpython-0.0.1a3.dist-info → basedpython-0.0.1a5.dist-info}/sboms/basedpython.cyclonedx.json +57 -22
- 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.1a5.dist-info}/WHEEL +0 -0
- {basedpython-0.0.1a3.dist-info → basedpython-0.0.1a5.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.1a5
|
|
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.1a5.data/scripts/buff.exe,sha256=JriGQZ5P_6_czwB3bCE3eOihS9O5hqX9unN4D7bUl58,28154368
|
|
2
|
+
basedpython-0.0.1a5.data/scripts/by.exe,sha256=5d2lRxk2lkw6edwwfcieex6ZaKaOxFOO4yq4z8tCzgQ,28020736
|
|
3
|
+
basedpython-0.0.1a5.dist-info/METADATA,sha256=nlY3nOoEO4n2D-mSjmz4CnDngYTlgZcQkqCZYDHWnhM,3119
|
|
4
|
+
basedpython-0.0.1a5.dist-info/WHEEL,sha256=JNKjfk8t_lLPebUae1rF2yydfqwhoTBTQSUGXxfneN4,90
|
|
5
|
+
basedpython-0.0.1a5.dist-info/licenses/LICENSE,sha256=JZfYVBIrd93HGXFWTKI1CjdghXXOMkrcVlCisgUcjxg,20731
|
|
6
|
+
basedpython-0.0.1a5.dist-info/sboms/basedpython.cyclonedx.json,sha256=F_ZoJ4TcA6qcgdVLnKJP_v1OMHOM85xpi-VZ4IfLX-A,434153
|
|
7
|
+
basedpython-0.0.1a5.dist-info/RECORD,,
|
{basedpython-0.0.1a3.dist-info → basedpython-0.0.1a5.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:5d344dea-89c8-4c7f-932d-08da9f0fa38c",
|
|
6
6
|
"metadata": {
|
|
7
|
-
"timestamp": "2026-07-
|
|
7
|
+
"timestamp": "2026-07-21T04:25:55.350778000Z",
|
|
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-a5",
|
|
18
18
|
"name": "basedpython",
|
|
19
|
-
"version": "0.0.1-
|
|
19
|
+
"version": "0.0.1-a5",
|
|
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-a5?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-a5 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-a5",
|
|
40
|
+
"purl": "pkg:cargo/basedpython@0.0.1-a5?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-a5 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-a5",
|
|
47
|
+
"purl": "pkg:cargo/basedpython@0.0.1-a5?download_url=file://.#src/by.rs"
|
|
48
48
|
}
|
|
49
49
|
]
|
|
50
50
|
},
|
|
@@ -9107,6 +9107,37 @@
|
|
|
9107
9107
|
}
|
|
9108
9108
|
]
|
|
9109
9109
|
},
|
|
9110
|
+
{
|
|
9111
|
+
"type": "library",
|
|
9112
|
+
"bom-ref": "registry+https://github.com/rust-lang/crates.io-index#unicode-segmentation@1.13.3",
|
|
9113
|
+
"author": "kwantam <kwantam@gmail.com>, Manish Goregaokar <manishsmail@gmail.com>",
|
|
9114
|
+
"name": "unicode-segmentation",
|
|
9115
|
+
"version": "1.13.3",
|
|
9116
|
+
"description": "This crate provides Grapheme Cluster, Word and Sentence boundaries according to Unicode Standard Annex #29 rules. ",
|
|
9117
|
+
"scope": "required",
|
|
9118
|
+
"hashes": [
|
|
9119
|
+
{
|
|
9120
|
+
"alg": "SHA-256",
|
|
9121
|
+
"content": "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
|
|
9122
|
+
}
|
|
9123
|
+
],
|
|
9124
|
+
"licenses": [
|
|
9125
|
+
{
|
|
9126
|
+
"expression": "MIT OR Apache-2.0"
|
|
9127
|
+
}
|
|
9128
|
+
],
|
|
9129
|
+
"purl": "pkg:cargo/unicode-segmentation@1.13.3",
|
|
9130
|
+
"externalReferences": [
|
|
9131
|
+
{
|
|
9132
|
+
"type": "website",
|
|
9133
|
+
"url": "https://github.com/unicode-rs/unicode-segmentation"
|
|
9134
|
+
},
|
|
9135
|
+
{
|
|
9136
|
+
"type": "vcs",
|
|
9137
|
+
"url": "https://github.com/unicode-rs/unicode-segmentation"
|
|
9138
|
+
}
|
|
9139
|
+
]
|
|
9140
|
+
},
|
|
9110
9141
|
{
|
|
9111
9142
|
"type": "library",
|
|
9112
9143
|
"bom-ref": "registry+https://github.com/rust-lang/crates.io-index#unicode-width@0.2.2",
|
|
@@ -10233,7 +10264,7 @@
|
|
|
10233
10264
|
],
|
|
10234
10265
|
"dependencies": [
|
|
10235
10266
|
{
|
|
10236
|
-
"ref": "path+file:///D:/a/basedpython/basedpython/crates/basedpython#0.0.1-
|
|
10267
|
+
"ref": "path+file:///D:/a/basedpython/basedpython/crates/basedpython#0.0.1-a5",
|
|
10237
10268
|
"dependsOn": [
|
|
10238
10269
|
"registry+https://github.com/rust-lang/crates.io-index#anyhow@1.0.102",
|
|
10239
10270
|
"registry+https://github.com/rust-lang/crates.io-index#argfile@1.0.0",
|
|
@@ -10989,7 +11020,8 @@
|
|
|
10989
11020
|
"registry+https://github.com/rust-lang/crates.io-index#tracing@0.1.44",
|
|
10990
11021
|
"path+file:///D:/a/basedpython/basedpython/crates/ty_module_resolver#0.0.3",
|
|
10991
11022
|
"path+file:///D:/a/basedpython/basedpython/crates/ty_python_core#0.0.3",
|
|
10992
|
-
"path+file:///D:/a/basedpython/basedpython/crates/ty_site_packages#0.0.3"
|
|
11023
|
+
"path+file:///D:/a/basedpython/basedpython/crates/ty_site_packages#0.0.3",
|
|
11024
|
+
"registry+https://github.com/rust-lang/crates.io-index#unicode-segmentation@1.13.3"
|
|
10993
11025
|
]
|
|
10994
11026
|
},
|
|
10995
11027
|
{
|
|
@@ -11097,7 +11129,7 @@
|
|
|
11097
11129
|
{
|
|
11098
11130
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#anstyle-query@1.1.5",
|
|
11099
11131
|
"dependsOn": [
|
|
11100
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
11132
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
11101
11133
|
]
|
|
11102
11134
|
},
|
|
11103
11135
|
{
|
|
@@ -11105,7 +11137,7 @@
|
|
|
11105
11137
|
"dependsOn": [
|
|
11106
11138
|
"registry+https://github.com/rust-lang/crates.io-index#anstyle@1.0.14",
|
|
11107
11139
|
"registry+https://github.com/rust-lang/crates.io-index#once_cell_polyfill@1.70.2",
|
|
11108
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
11140
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
11109
11141
|
]
|
|
11110
11142
|
},
|
|
11111
11143
|
{
|
|
@@ -11300,7 +11332,7 @@
|
|
|
11300
11332
|
"registry+https://github.com/rust-lang/crates.io-index#terminfo@0.9.0",
|
|
11301
11333
|
"registry+https://github.com/rust-lang/crates.io-index#thiserror@2.0.18",
|
|
11302
11334
|
"registry+https://github.com/rust-lang/crates.io-index#which@8.0.2",
|
|
11303
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
11335
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
11304
11336
|
]
|
|
11305
11337
|
},
|
|
11306
11338
|
{
|
|
@@ -11312,7 +11344,7 @@
|
|
|
11312
11344
|
{
|
|
11313
11345
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#colored@3.1.1",
|
|
11314
11346
|
"dependsOn": [
|
|
11315
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
11347
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
11316
11348
|
]
|
|
11317
11349
|
},
|
|
11318
11350
|
{
|
|
@@ -11415,7 +11447,7 @@
|
|
|
11415
11447
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#dirs-sys@0.5.0",
|
|
11416
11448
|
"dependsOn": [
|
|
11417
11449
|
"registry+https://github.com/rust-lang/crates.io-index#option-ext@0.2.0",
|
|
11418
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
11450
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
11419
11451
|
]
|
|
11420
11452
|
},
|
|
11421
11453
|
{
|
|
@@ -11923,7 +11955,7 @@
|
|
|
11923
11955
|
{
|
|
11924
11956
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#nu-ansi-term@0.50.3",
|
|
11925
11957
|
"dependsOn": [
|
|
11926
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
11958
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
11927
11959
|
]
|
|
11928
11960
|
},
|
|
11929
11961
|
{
|
|
@@ -12508,13 +12540,13 @@
|
|
|
12508
12540
|
"registry+https://github.com/rust-lang/crates.io-index#fastrand@2.4.1",
|
|
12509
12541
|
"registry+https://github.com/rust-lang/crates.io-index#getrandom@0.4.2",
|
|
12510
12542
|
"registry+https://github.com/rust-lang/crates.io-index#once_cell@1.21.4",
|
|
12511
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
12543
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
12512
12544
|
]
|
|
12513
12545
|
},
|
|
12514
12546
|
{
|
|
12515
12547
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#terminal_size@0.4.4",
|
|
12516
12548
|
"dependsOn": [
|
|
12517
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
12549
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
12518
12550
|
]
|
|
12519
12551
|
},
|
|
12520
12552
|
{
|
|
@@ -12699,6 +12731,9 @@
|
|
|
12699
12731
|
"registry+https://github.com/rust-lang/crates.io-index#tinyvec@1.11.0"
|
|
12700
12732
|
]
|
|
12701
12733
|
},
|
|
12734
|
+
{
|
|
12735
|
+
"ref": "registry+https://github.com/rust-lang/crates.io-index#unicode-segmentation@1.13.3"
|
|
12736
|
+
},
|
|
12702
12737
|
{
|
|
12703
12738
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#unicode-width@0.2.2"
|
|
12704
12739
|
},
|
|
@@ -12777,7 +12812,7 @@
|
|
|
12777
12812
|
{
|
|
12778
12813
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#winapi-util@0.1.11",
|
|
12779
12814
|
"dependsOn": [
|
|
12780
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
12815
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
12781
12816
|
]
|
|
12782
12817
|
},
|
|
12783
12818
|
{
|
|
@@ -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=U2SMG3U1ietbkaCfdAro0jccMZlt32Z-AhykqQYAHhs,28153344
|
|
2
|
-
basedpython-0.0.1a3.data/scripts/by.exe,sha256=Tbmwh84OnWv04k64rwoOkPyeRZNaqGLzmbxpt-i4FZQ,27022336
|
|
3
|
-
basedpython-0.0.1a3.dist-info/METADATA,sha256=c08hWqPV-4cH94yg0l1O9jWq7FVKDIgC4HDMkeUsYSI,10969
|
|
4
|
-
basedpython-0.0.1a3.dist-info/WHEEL,sha256=JNKjfk8t_lLPebUae1rF2yydfqwhoTBTQSUGXxfneN4,90
|
|
5
|
-
basedpython-0.0.1a3.dist-info/licenses/LICENSE,sha256=JZfYVBIrd93HGXFWTKI1CjdghXXOMkrcVlCisgUcjxg,20731
|
|
6
|
-
basedpython-0.0.1a3.dist-info/sboms/basedpython.cyclonedx.json,sha256=Hww1Ic0l72NGpI-oy2l_N5uQNpJbQnjEw4maN5p3EiM,432905
|
|
7
|
-
basedpython-0.0.1a3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|