basedpython 0.0.1a3__py3-none-win_arm64.whl → 0.0.1a5__py3-none-win_arm64.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=_4p21DXpPjgBD51tZr2kQS3xL9nhIkUropUp_1DrGK8,29883904
|
|
2
|
+
basedpython-0.0.1a5.data/scripts/by.exe,sha256=GtMThqgehL_qWG5svM91GMUaM8tJMiCqoAunWu7fd-M,30007808
|
|
3
|
+
basedpython-0.0.1a5.dist-info/METADATA,sha256=nlY3nOoEO4n2D-mSjmz4CnDngYTlgZcQkqCZYDHWnhM,3119
|
|
4
|
+
basedpython-0.0.1a5.dist-info/WHEEL,sha256=HFYih4WXcC5rmYTuselhEbrQhijkWBtMrfSegtgvPSA,94
|
|
5
|
+
basedpython-0.0.1a5.dist-info/licenses/LICENSE,sha256=JZfYVBIrd93HGXFWTKI1CjdghXXOMkrcVlCisgUcjxg,20731
|
|
6
|
+
basedpython-0.0.1a5.dist-info/sboms/basedpython.cyclonedx.json,sha256=OLE2zQVuhyDy-bSoGvI14oVpqwS2GWVztbqEDlAbSt8,432996
|
|
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:228ccc6d-c69d-43a8-bc2d-69e97966468e",
|
|
6
6
|
"metadata": {
|
|
7
|
-
"timestamp": "2026-07-
|
|
7
|
+
"timestamp": "2026-07-21T04:28:26.919463500Z",
|
|
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
|
},
|
|
@@ -9076,6 +9076,37 @@
|
|
|
9076
9076
|
}
|
|
9077
9077
|
]
|
|
9078
9078
|
},
|
|
9079
|
+
{
|
|
9080
|
+
"type": "library",
|
|
9081
|
+
"bom-ref": "registry+https://github.com/rust-lang/crates.io-index#unicode-segmentation@1.13.3",
|
|
9082
|
+
"author": "kwantam <kwantam@gmail.com>, Manish Goregaokar <manishsmail@gmail.com>",
|
|
9083
|
+
"name": "unicode-segmentation",
|
|
9084
|
+
"version": "1.13.3",
|
|
9085
|
+
"description": "This crate provides Grapheme Cluster, Word and Sentence boundaries according to Unicode Standard Annex #29 rules. ",
|
|
9086
|
+
"scope": "required",
|
|
9087
|
+
"hashes": [
|
|
9088
|
+
{
|
|
9089
|
+
"alg": "SHA-256",
|
|
9090
|
+
"content": "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
|
|
9091
|
+
}
|
|
9092
|
+
],
|
|
9093
|
+
"licenses": [
|
|
9094
|
+
{
|
|
9095
|
+
"expression": "MIT OR Apache-2.0"
|
|
9096
|
+
}
|
|
9097
|
+
],
|
|
9098
|
+
"purl": "pkg:cargo/unicode-segmentation@1.13.3",
|
|
9099
|
+
"externalReferences": [
|
|
9100
|
+
{
|
|
9101
|
+
"type": "website",
|
|
9102
|
+
"url": "https://github.com/unicode-rs/unicode-segmentation"
|
|
9103
|
+
},
|
|
9104
|
+
{
|
|
9105
|
+
"type": "vcs",
|
|
9106
|
+
"url": "https://github.com/unicode-rs/unicode-segmentation"
|
|
9107
|
+
}
|
|
9108
|
+
]
|
|
9109
|
+
},
|
|
9079
9110
|
{
|
|
9080
9111
|
"type": "library",
|
|
9081
9112
|
"bom-ref": "registry+https://github.com/rust-lang/crates.io-index#unicode-width@0.2.2",
|
|
@@ -10202,7 +10233,7 @@
|
|
|
10202
10233
|
],
|
|
10203
10234
|
"dependencies": [
|
|
10204
10235
|
{
|
|
10205
|
-
"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-a5",
|
|
10206
10237
|
"dependsOn": [
|
|
10207
10238
|
"registry+https://github.com/rust-lang/crates.io-index#anyhow@1.0.102",
|
|
10208
10239
|
"registry+https://github.com/rust-lang/crates.io-index#argfile@1.0.0",
|
|
@@ -10958,7 +10989,8 @@
|
|
|
10958
10989
|
"registry+https://github.com/rust-lang/crates.io-index#tracing@0.1.44",
|
|
10959
10990
|
"path+file:///D:/a/basedpython/basedpython/crates/ty_module_resolver#0.0.3",
|
|
10960
10991
|
"path+file:///D:/a/basedpython/basedpython/crates/ty_python_core#0.0.3",
|
|
10961
|
-
"path+file:///D:/a/basedpython/basedpython/crates/ty_site_packages#0.0.3"
|
|
10992
|
+
"path+file:///D:/a/basedpython/basedpython/crates/ty_site_packages#0.0.3",
|
|
10993
|
+
"registry+https://github.com/rust-lang/crates.io-index#unicode-segmentation@1.13.3"
|
|
10962
10994
|
]
|
|
10963
10995
|
},
|
|
10964
10996
|
{
|
|
@@ -11066,7 +11098,7 @@
|
|
|
11066
11098
|
{
|
|
11067
11099
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#anstyle-query@1.1.5",
|
|
11068
11100
|
"dependsOn": [
|
|
11069
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
11101
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
11070
11102
|
]
|
|
11071
11103
|
},
|
|
11072
11104
|
{
|
|
@@ -11074,7 +11106,7 @@
|
|
|
11074
11106
|
"dependsOn": [
|
|
11075
11107
|
"registry+https://github.com/rust-lang/crates.io-index#anstyle@1.0.14",
|
|
11076
11108
|
"registry+https://github.com/rust-lang/crates.io-index#once_cell_polyfill@1.70.2",
|
|
11077
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
11109
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
11078
11110
|
]
|
|
11079
11111
|
},
|
|
11080
11112
|
{
|
|
@@ -11268,7 +11300,7 @@
|
|
|
11268
11300
|
"registry+https://github.com/rust-lang/crates.io-index#terminfo@0.9.0",
|
|
11269
11301
|
"registry+https://github.com/rust-lang/crates.io-index#thiserror@2.0.18",
|
|
11270
11302
|
"registry+https://github.com/rust-lang/crates.io-index#which@8.0.2",
|
|
11271
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
11303
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
11272
11304
|
]
|
|
11273
11305
|
},
|
|
11274
11306
|
{
|
|
@@ -11280,7 +11312,7 @@
|
|
|
11280
11312
|
{
|
|
11281
11313
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#colored@3.1.1",
|
|
11282
11314
|
"dependsOn": [
|
|
11283
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
11315
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
11284
11316
|
]
|
|
11285
11317
|
},
|
|
11286
11318
|
{
|
|
@@ -11380,7 +11412,7 @@
|
|
|
11380
11412
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#dirs-sys@0.5.0",
|
|
11381
11413
|
"dependsOn": [
|
|
11382
11414
|
"registry+https://github.com/rust-lang/crates.io-index#option-ext@0.2.0",
|
|
11383
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
11415
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
11384
11416
|
]
|
|
11385
11417
|
},
|
|
11386
11418
|
{
|
|
@@ -11888,7 +11920,7 @@
|
|
|
11888
11920
|
{
|
|
11889
11921
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#nu-ansi-term@0.50.3",
|
|
11890
11922
|
"dependsOn": [
|
|
11891
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
11923
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
11892
11924
|
]
|
|
11893
11925
|
},
|
|
11894
11926
|
{
|
|
@@ -12473,13 +12505,13 @@
|
|
|
12473
12505
|
"registry+https://github.com/rust-lang/crates.io-index#fastrand@2.4.1",
|
|
12474
12506
|
"registry+https://github.com/rust-lang/crates.io-index#getrandom@0.4.2",
|
|
12475
12507
|
"registry+https://github.com/rust-lang/crates.io-index#once_cell@1.21.4",
|
|
12476
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
12508
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
12477
12509
|
]
|
|
12478
12510
|
},
|
|
12479
12511
|
{
|
|
12480
12512
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#terminal_size@0.4.4",
|
|
12481
12513
|
"dependsOn": [
|
|
12482
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
12514
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
12483
12515
|
]
|
|
12484
12516
|
},
|
|
12485
12517
|
{
|
|
@@ -12664,6 +12696,9 @@
|
|
|
12664
12696
|
"registry+https://github.com/rust-lang/crates.io-index#tinyvec@1.11.0"
|
|
12665
12697
|
]
|
|
12666
12698
|
},
|
|
12699
|
+
{
|
|
12700
|
+
"ref": "registry+https://github.com/rust-lang/crates.io-index#unicode-segmentation@1.13.3"
|
|
12701
|
+
},
|
|
12667
12702
|
{
|
|
12668
12703
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#unicode-width@0.2.2"
|
|
12669
12704
|
},
|
|
@@ -12742,7 +12777,7 @@
|
|
|
12742
12777
|
{
|
|
12743
12778
|
"ref": "registry+https://github.com/rust-lang/crates.io-index#winapi-util@0.1.11",
|
|
12744
12779
|
"dependsOn": [
|
|
12745
|
-
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.
|
|
12780
|
+
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.60.2"
|
|
12746
12781
|
]
|
|
12747
12782
|
},
|
|
12748
12783
|
{
|
|
@@ -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=36zWI6_TNgMCfGsFRCfG_6SASJmO_TQOwNRz5NcvJuE,29761536
|
|
2
|
-
basedpython-0.0.1a3.data/scripts/by.exe,sha256=WNUZdgGiq6qpb_MSZ6IyoqThM1eUdU1rPoLVt9Hs9Bs,29021184
|
|
3
|
-
basedpython-0.0.1a3.dist-info/METADATA,sha256=c08hWqPV-4cH94yg0l1O9jWq7FVKDIgC4HDMkeUsYSI,10969
|
|
4
|
-
basedpython-0.0.1a3.dist-info/WHEEL,sha256=HFYih4WXcC5rmYTuselhEbrQhijkWBtMrfSegtgvPSA,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=ZxcaO98fZJG-m3SkMFHtNfNC3WaWk0lzQ2Kc92fia1Q,431748
|
|
7
|
-
basedpython-0.0.1a3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|