Skip to content

Commit c6288e8

Browse files
committed
features
1 parent cc08a54 commit c6288e8

8,564 files changed

Lines changed: 1349929 additions & 827 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 4137 additions & 455 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 179 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ path = "src/lib.rs"
1515
ruff_python_parser = { workspace = true }
1616
ruff_python_ast = { workspace = true }
1717
ruff_text_size = { workspace = true }
18-
clap = { version = "4", features = ["derive"] }
18+
ty = { workspace = true }
19+
clap = { version = "4", features = ["derive", "wrap_help", "string", "env"] }
20+
clap_complete_command = { workspace = true }
1921
tempfile = "3"
2022
walkdir = "2"
2123

@@ -28,6 +30,10 @@ indoc = "2"
2830
# basedpython vendors crates from astral-sh/ruff under `crates/` so we
2931
# can extend the Python grammar/AST for basedpython-specific syntax without
3032
# depending on a remote branch. Upstream ref: see docs/ruff-upstream-sync.md.
33+
#
34+
# we also vendor the full ruff CLI crates to build `buff`, a 1-to-1 drop-in
35+
# replacement for `ruff` that natively understands `.by` files. crate names
36+
# match upstream exactly to keep upstream merges mechanical.
3137
# ---------------------------------------------------------------------------
3238

3339
[workspace]
@@ -41,53 +47,202 @@ default-members = ["."]
4147
[workspace.package]
4248
edition = "2024"
4349
rust-version = "1.93"
44-
homepage = "https://github.com/morganbartholomew/basedpython"
45-
documentation = "https://github.com/morganbartholomew/basedpython"
46-
repository = "https://github.com/morganbartholomew/basedpython"
47-
authors = ["Morgan Bartholomew"]
50+
homepage = "https://github.com/KotlinIsland/basedpython"
51+
documentation = "https://github.com/KotlinIsland/basedpython"
52+
repository = "https://github.com/KotlinIsland/basedpython"
53+
authors = ["KotlinIsland"]
4854
license = "MIT"
4955

5056
[workspace.dependencies]
51-
# vendored ruff crates
57+
# vendored ruff crates — parser/AST (extended for basedpython syntax)
5258
ruff_annotate_snippets = { path = "crates/ruff_annotate_snippets" }
5359
ruff_python_ast = { path = "crates/ruff_python_ast" }
5460
ruff_python_parser = { path = "crates/ruff_python_parser" }
5561
ruff_python_trivia = { path = "crates/ruff_python_trivia" }
5662
ruff_source_file = { path = "crates/ruff_source_file" }
5763
ruff_text_size = { path = "crates/ruff_text_size" }
5864

59-
# external crates used by the vendored set. versions match ruff's pin at the
60-
# vendored SHA so swapping in/out is mechanical
65+
# vendored ruff crates — formatter, linter, LSP, and CLI (→ buff binary)
66+
ruff = { path = "crates/ruff" }
67+
ruff_cache = { path = "crates/ruff_cache" }
68+
ruff_db = { path = "crates/ruff_db", default-features = false }
69+
ruff_diagnostics = { path = "crates/ruff_diagnostics" }
70+
ruff_formatter = { path = "crates/ruff_formatter" }
71+
ruff_graph = { path = "crates/ruff_graph" }
72+
ruff_index = { path = "crates/ruff_index" }
73+
ruff_linter = { path = "crates/ruff_linter" }
74+
ruff_macros = { path = "crates/ruff_macros" }
75+
ruff_markdown = { path = "crates/ruff_markdown" }
76+
ruff_notebook = { path = "crates/ruff_notebook" }
77+
ruff_options_metadata = { path = "crates/ruff_options_metadata" }
78+
ruff_python_codegen = { path = "crates/ruff_python_codegen" }
79+
ruff_python_formatter = { path = "crates/ruff_python_formatter" }
80+
ruff_python_importer = { path = "crates/ruff_python_importer" }
81+
ruff_python_index = { path = "crates/ruff_python_index" }
82+
ruff_python_literal = { path = "crates/ruff_python_literal" }
83+
ruff_python_semantic = { path = "crates/ruff_python_semantic" }
84+
ruff_python_stdlib = { path = "crates/ruff_python_stdlib" }
85+
ruff_server = { path = "crates/ruff_server" }
86+
ruff_memory_usage = { path = "crates/ruff_memory_usage" }
87+
ruff_workspace = { path = "crates/ruff_workspace" }
88+
89+
# vendored ty crates — full suite for `by` (drop-in replacement for `ty`)
90+
ty = { path = "crates/ty" }
91+
ty_combine = { path = "crates/ty_combine" }
92+
ty_ide = { path = "crates/ty_ide" }
93+
ty_module_resolver = { path = "crates/ty_module_resolver" }
94+
ty_project = { path = "crates/ty_project" }
95+
ty_python_core = { path = "crates/ty_python_core" }
96+
ty_python_semantic = { path = "crates/ty_python_semantic" }
97+
ty_server = { path = "crates/ty_server" }
98+
ty_site_packages = { path = "crates/ty_site_packages" }
99+
ty_static = { path = "crates/ty_static" }
100+
ty_test = { path = "crates/ty_test" }
101+
mdtest = { path = "crates/mdtest" }
102+
ty_vendored = { path = "crates/ty_vendored" }
103+
104+
# external crates — versions match ruff's pin at vendored SHA
61105
aho-corasick = { version = "1.1.3" }
62106
anstream = { version = "1.0.0" }
63107
anstyle = { version = "1.0.10" }
64108
anyhow = { version = "1.0.80" }
109+
arc-swap = { version = "1.7.1" }
110+
argfile = { version = "1.0.0" }
111+
assert_fs = { version = "1.1.0" }
112+
bincode = { version = "2.0.0" }
65113
bitflags = { version = "2.5.0" }
114+
bitvec = { version = "1.0.1", default-features = false, features = ["alloc"] }
66115
bstr = { version = "1.9.1" }
116+
cachedir = { version = "0.3.1" }
117+
camino = { version = "1.1.7" }
118+
clap = { version = "4.5.3", features = ["derive"] }
119+
clap_complete_command = { version = "0.6.0" }
120+
clearscreen = { version = "4.0.0" }
121+
codspeed-criterion-compat = { version = "4.4.1", default-features = false }
122+
colored = { version = "3.0.0" }
67123
compact_str = "0.9.0"
124+
countme = { version = "3.0.1" }
125+
criterion = { version = "0.8.0", default-features = false }
126+
crossbeam = { version = "0.8.4" }
127+
ctrlc = { version = "3.4.4" }
128+
csv = { version = "1.3.1" }
129+
dashmap = { version = "6.0.1" }
68130
datatest-stable = { version = "0.3.3" }
131+
divan = { package = "codspeed-divan-compat", version = "4.4.1" }
132+
drop_bomb = { version = "0.1.5" }
133+
dunce = { version = "1.0.5" }
134+
etcetera = { version = "0.11.0" }
135+
fern = { version = "0.7.0" }
136+
filetime = { version = "0.2.23" }
69137
get-size2 = { version = "0.7.3", features = [
70138
"derive",
71139
"smallvec",
72140
"hashbrown",
73141
"compact-str",
74142
"ordermap",
75143
] }
144+
getrandom = { version = "0.4.1" }
145+
glob = { version = "0.3.1" }
146+
globset = { version = "0.4.14" }
147+
globwalk = { version = "0.9.1" }
148+
hashbrown = { version = "0.16.0", default-features = false, features = [
149+
"raw-entry",
150+
"equivalent",
151+
"inline-more",
152+
] }
153+
heck = "0.5.0"
154+
icu_properties = { version = "2.1.2" }
155+
ignore = { version = "0.4.24" }
156+
imara-diff = { version = "0.2.0" }
157+
imperative = { version = "1.0.4" }
158+
indexmap = { version = "2.6.0" }
159+
indicatif = { version = "0.18.0" }
160+
indoc = { version = "2.0.4" }
76161
insta = { version = "1.35.1" }
162+
insta-cmd = { version = "0.6.0" }
77163
is-macro = { version = "0.3.5" }
78164
itertools = { version = "0.14.0" }
165+
jiff = { version = "0.2.0" }
166+
jod-thread = { version = "1.0.0" }
167+
libc = { version = "0.2.153" }
168+
libcst = { version = "1.8.4", default-features = false }
169+
log = { version = "0.4.17" }
170+
lsp-server = { version = "0.7.6" }
171+
lsp-types = { git = "https://github.com/astral-sh/lsp-types.git", rev = "e15db0593f0ecbbd80599c3f5880e4bf5da1ca0c", features = ["proposed"] }
172+
matchit = { version = "0.9.0" }
79173
memchr = { version = "2.7.1" }
174+
mimalloc = { version = "0.1.39" }
175+
natord = { version = "1.0.9" }
176+
notify = { version = "8.0.0" }
177+
once_cell = { version = "1.21.4" }
178+
ordermap = { version = "1.0.0" }
179+
path-absolutize = { version = "3.1.1", features = ["once_cell_cache"] }
180+
path-slash = { version = "0.2.1" }
181+
pathdiff = { version = "0.2.1" }
182+
pep440_rs = { version = "0.7.1" }
183+
pretty_assertions = "1.3.0"
184+
proc-macro2 = { version = "1.0.79" }
185+
pyproject-toml = { version = "0.13.4" }
186+
quick-junit = { version = "0.6.0" }
187+
quickcheck = { version = "1.0.3", default-features = false }
188+
quickcheck_macros = { version = "1.0.0" }
189+
quote = { version = "1.0.23" }
190+
rand = { version = "0.10.0" }
191+
rayon = { version = "1.10.0" }
192+
regex = { version = "1.10.2" }
193+
regex-automata = { version = "0.4.9" }
194+
regex-syntax = { version = "0.8.8" }
80195
rustc-hash = { version = "2.0.0" }
196+
rustc-stable-hash = { version = "0.1.2" }
197+
# pinned git dep — ruff_db and ruff_server depend on this for incremental computation
198+
salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "2f687a17ceea8ec7aaa605561ccbde938ccef086", default-features = false, features = [
199+
"compact_str",
200+
"macros",
201+
"salsa_unstable",
202+
"inventory",
203+
] }
204+
schemars = { version = "1.0.4" }
205+
seahash = { version = "4.1.0" }
81206
serde = { version = "1.0.197", features = ["derive"] }
82207
serde_json = { version = "1.0.113" }
83208
serde_test = { version = "1.0.152" }
209+
serde_with = { version = "3.6.0", default-features = false, features = ["macros"] }
210+
shellexpand = { version = "3.0.0" }
211+
similar = { version = "3.0.0", features = ["inline"] }
212+
smallvec = { version = "1.13.2", features = ["union", "const_generics", "const_new"] }
213+
snapbox = { version = "1.0.0", features = ["diff", "term-svg", "cmd", "examples"] }
84214
static_assertions = "1.1.0"
215+
strum = { version = "0.28.0", features = ["strum_macros"] }
216+
strum_macros = { version = "0.28.0" }
217+
supports-hyperlinks = { version = "3.1.0" }
218+
syn = { version = "2.0.55" }
219+
tempfile = { version = "3.9.0" }
220+
test-case = { version = "3.3.1" }
85221
thiserror = { version = "2.0.0" }
222+
tikv-jemallocator = { version = "0.6.0" }
223+
toml = { version = "1.0.0" }
224+
tracing = { version = "0.1.40" }
225+
tracing-flame = { version = "0.2.0" }
226+
tracing-indicatif = { version = "0.3.11" }
227+
tracing-log = { version = "0.2.0" }
228+
tracing-subscriber = { version = "0.3.18", default-features = false, features = [
229+
"env-filter",
230+
"fmt",
231+
"ansi",
232+
"smallvec",
233+
] }
234+
tryfn = { version = "1.0.0" }
235+
typed-arena = { version = "2.0.2" }
86236
unicode-ident = { version = "1.0.12" }
87237
unicode-normalization = { version = "0.1.23" }
88238
unicode-width = { version = "0.2.0" }
89239
unicode_names2 = { version = "1.2.2" }
240+
url = { version = "2.5.0" }
241+
uuid = { version = "1.6.1", features = ["v4", "fast-rng", "macro-diagnostics"] }
90242
walkdir = { version = "2.3.2" }
243+
which = { version = "8.0.0" }
244+
wild = { version = "2" }
245+
zip = { version = "0.6.6", default-features = false }
91246

92247
[workspace.lints.rust]
93248
unsafe_code = "warn"
@@ -134,6 +289,10 @@ unused_peekable = "warn"
134289
if_not_else = "allow"
135290
large_stack_arrays = "allow"
136291

292+
[profile.release]
293+
lto = "fat"
294+
codegen-units = 16
295+
137296
# Parser benefits from codegen-units=1 in release builds.
138297
[profile.release.package.ruff_python_parser]
139298
codegen-units = 1
@@ -143,3 +302,15 @@ codegen-units = 1
143302
# Keeping parser dev builds compatible with wasm tools' local limits.
144303
[profile.dev.package.ruff_python_parser]
145304
opt-level = 1
305+
306+
[profile.dev.package.insta]
307+
opt-level = 3
308+
309+
[profile.dev.package.similar]
310+
opt-level = 3
311+
312+
[profile.release.package.salsa]
313+
codegen-units = 1
314+
315+
[profile.dev.package.salsa]
316+
opt-level = 3

README.md

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,6 @@ by --min-version 3.12 build
3232

3333
## features
3434

35-
### subscription normalization
36-
37-
tuple subscripts are normalized so the key is an unambiguous 1-tuple:
38-
39-
```python
40-
# input
41-
x[(a, b)]
42-
x[a, b]
43-
44-
# output
45-
x[(a, b),]
46-
x[(a, b),]
47-
```
48-
49-
this eliminates the inconsistency with call expressions and visual ambiguity between `x[(a, b)]` (tuple key) and `x[a]` (scalar key)
50-
5135
### mutable default argument via lazy evaluation
5236

5337
mutable default arguments are automatically rewritten to the sentinel pattern:
@@ -58,6 +42,7 @@ def f(x=[], y={}):
5842
pass
5943

6044
# output
45+
_MISSING = object()
6146
def f(x=_MISSING, y=_MISSING):
6247
if x is _MISSING:
6348
x = []
@@ -66,6 +51,10 @@ def f(x=_MISSING, y=_MISSING):
6651
pass
6752
```
6853

54+
### callable syntax
55+
56+
#### TODO
57+
6958
### python version polyfills
7059

7160
when `--min-version` is below the version that introduced a feature, basedpython rewrites it to an equivalent that runs on the target. all polyfills are no-ops when targeting a version that has the feature natively
@@ -115,11 +104,12 @@ math.exp2(x) → 2 ** (x)
115104

116105
### multiline strings
117106

118-
# TODO
107+
#### TODO
119108

120109
### None operators
121110

122-
# TODO
111+
`?.` `??`
112+
#### TODO
123113

124114
### modifier keywords
125115

@@ -134,8 +124,15 @@ final data class A:
134124
class def bar(): ...
135125

136126
static def baz(): ...
137-
```
138127

128+
enum B:
129+
a, b, c
130+
131+
protocol C:
132+
a: int
133+
134+
newtype MyInt = int
135+
```
139136

140137
### visibility modifiers
141138

@@ -155,3 +152,20 @@ __all__ = ["api"]
155152
```
156153

157154
`export`/`public` adds the symbol's name to an auto-generated `__all__` list. `private` strips the modifier and renames the declaration with a leading underscore (the conventional Python "internal" marker). Both apply to `def` and `class` at module scope; inside a class body the modifier is stripped without renaming or affecting `__all__`
155+
156+
### subscription normalization
157+
158+
tuple subscripts are normalized so the key is an unambiguous 1-tuple:
159+
160+
```python
161+
# input
162+
x[(a, b)]
163+
x[a, b]
164+
165+
# output
166+
x[(a, b),]
167+
x[(a, b),]
168+
```
169+
170+
this eliminates the inconsistency with call expressions and visual ambiguity between `x[(a, b)]` (tuple key) and `x[a]` (scalar key)
171+

0 commit comments

Comments
 (0)