rlbot-flatbuffers 0.18.1__tar.gz → 0.18.3__tar.gz

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.
Files changed (26) hide show
  1. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/Cargo.lock +24 -18
  2. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/Cargo.toml +1 -1
  3. rlbot_flatbuffers-0.18.3/PKG-INFO +139 -0
  4. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/codegen/main.rs +1 -1
  5. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/codegen/pyi.rs +61 -46
  6. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/pyproject.toml +4 -1
  7. rlbot_flatbuffers-0.18.1/PKG-INFO +0 -8
  8. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/LICENSE +0 -0
  9. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/README.md +0 -0
  10. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/codegen/class_inject.rs +0 -0
  11. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/codegen/enums.rs +0 -0
  12. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/codegen/structs.rs +0 -0
  13. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/codegen/table.rs +0 -0
  14. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/codegen/unions.rs +0 -0
  15. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/flatbuffers-schema/schema/color.fbs +0 -0
  16. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/flatbuffers-schema/schema/comms.fbs +0 -0
  17. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/flatbuffers-schema/schema/corepacket.fbs +0 -0
  18. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/flatbuffers-schema/schema/gamedata.fbs +0 -0
  19. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/flatbuffers-schema/schema/gamestatemanip.fbs +0 -0
  20. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/flatbuffers-schema/schema/interfacepacket.fbs +0 -0
  21. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/flatbuffers-schema/schema/matchconfig.fbs +0 -0
  22. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/flatbuffers-schema/schema/misc.fbs +0 -0
  23. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/flatbuffers-schema/schema/rendering.fbs +0 -0
  24. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/flatbuffers-schema/schema/rlbot.fbs +0 -0
  25. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/flatbuffers-schema/schema/vector.fbs +0 -0
  26. {rlbot_flatbuffers-0.18.1 → rlbot_flatbuffers-0.18.3}/src/lib.rs +0 -0
@@ -292,6 +292,12 @@ dependencies = [
292
292
  "foldhash",
293
293
  ]
294
294
 
295
+ [[package]]
296
+ name = "hashbrown"
297
+ version = "0.16.0"
298
+ source = "registry+https://github.com/rust-lang/crates.io-index"
299
+ checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
300
+
295
301
  [[package]]
296
302
  name = "heck"
297
303
  version = "0.5.0"
@@ -315,12 +321,12 @@ checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5"
315
321
 
316
322
  [[package]]
317
323
  name = "indexmap"
318
- version = "2.11.1"
324
+ version = "2.11.4"
319
325
  source = "registry+https://github.com/rust-lang/crates.io-index"
320
- checksum = "206a8042aec68fa4a62e8d3f7aa4ceb508177d9324faf261e1959e495b7a1921"
326
+ checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
321
327
  dependencies = [
322
328
  "equivalent",
323
- "hashbrown",
329
+ "hashbrown 0.16.0",
324
330
  ]
325
331
 
326
332
  [[package]]
@@ -575,7 +581,7 @@ version = "1.1.1"
575
581
  source = "git+https://github.com/swz-git/planus?rev=a0b1fbf#a0b1fbf28458389e2d3dc7598d257231103d9497"
576
582
  dependencies = [
577
583
  "array-init-cursor",
578
- "hashbrown",
584
+ "hashbrown 0.15.5",
579
585
  ]
580
586
 
581
587
  [[package]]
@@ -815,7 +821,7 @@ checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001"
815
821
 
816
822
  [[package]]
817
823
  name = "rlbot_flatbuffers"
818
- version = "0.18.1"
824
+ version = "0.18.3"
819
825
  dependencies = [
820
826
  "eyre",
821
827
  "indexmap",
@@ -864,9 +870,9 @@ checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
864
870
 
865
871
  [[package]]
866
872
  name = "serde"
867
- version = "1.0.223"
873
+ version = "1.0.226"
868
874
  source = "registry+https://github.com/rust-lang/crates.io-index"
869
- checksum = "a505d71960adde88e293da5cb5eda57093379f64e61cf77bf0e6a63af07a7bac"
875
+ checksum = "0dca6411025b24b60bfa7ec1fe1f8e710ac09782dca409ee8237ba74b51295fd"
870
876
  dependencies = [
871
877
  "serde_core",
872
878
  "serde_derive",
@@ -874,18 +880,18 @@ dependencies = [
874
880
 
875
881
  [[package]]
876
882
  name = "serde_core"
877
- version = "1.0.223"
883
+ version = "1.0.226"
878
884
  source = "registry+https://github.com/rust-lang/crates.io-index"
879
- checksum = "20f57cbd357666aa7b3ac84a90b4ea328f1d4ddb6772b430caa5d9e1309bb9e9"
885
+ checksum = "ba2ba63999edb9dac981fb34b3e5c0d111a69b0924e253ed29d83f7c99e966a4"
880
886
  dependencies = [
881
887
  "serde_derive",
882
888
  ]
883
889
 
884
890
  [[package]]
885
891
  name = "serde_derive"
886
- version = "1.0.223"
892
+ version = "1.0.226"
887
893
  source = "registry+https://github.com/rust-lang/crates.io-index"
888
- checksum = "3d428d07faf17e306e699ec1e91996e5a165ba5d6bce5b5155173e91a8a01a56"
894
+ checksum = "8db53ae22f34573731bafa1db20f04027b2d25e02d8205921b569171699cdb33"
889
895
  dependencies = [
890
896
  "proc-macro2",
891
897
  "quote",
@@ -920,7 +926,7 @@ version = "0.19.0"
920
926
  source = "registry+https://github.com/rust-lang/crates.io-index"
921
927
  checksum = "23de088478b31c349c9ba67816fa55d9355232d63c3afea8bf513e31f0f1d2c0"
922
928
  dependencies = [
923
- "hashbrown",
929
+ "hashbrown 0.15.5",
924
930
  "serde",
925
931
  ]
926
932
 
@@ -1057,18 +1063,18 @@ dependencies = [
1057
1063
 
1058
1064
  [[package]]
1059
1065
  name = "wasi"
1060
- version = "0.14.5+wasi-0.2.4"
1066
+ version = "0.14.7+wasi-0.2.4"
1061
1067
  source = "registry+https://github.com/rust-lang/crates.io-index"
1062
- checksum = "a4494f6290a82f5fe584817a676a34b9d6763e8d9d18204009fb31dceca98fd4"
1068
+ checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c"
1063
1069
  dependencies = [
1064
1070
  "wasip2",
1065
1071
  ]
1066
1072
 
1067
1073
  [[package]]
1068
1074
  name = "wasip2"
1069
- version = "1.0.0+wasi-0.2.4"
1075
+ version = "1.0.1+wasi-0.2.4"
1070
1076
  source = "registry+https://github.com/rust-lang/crates.io-index"
1071
- checksum = "03fa2761397e5bd52002cd7e73110c71af2109aca4e521a9f40473fe685b0a24"
1077
+ checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
1072
1078
  dependencies = [
1073
1079
  "wit-bindgen",
1074
1080
  ]
@@ -1163,9 +1169,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
1163
1169
 
1164
1170
  [[package]]
1165
1171
  name = "wit-bindgen"
1166
- version = "0.45.1"
1172
+ version = "0.46.0"
1167
1173
  source = "registry+https://github.com/rust-lang/crates.io-index"
1168
- checksum = "5c573471f125075647d03df72e026074b7203790d41351cd6edc96f46bcccd36"
1174
+ checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
1169
1175
 
1170
1176
  [[package]]
1171
1177
  name = "zerocopy"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "rlbot_flatbuffers"
3
- version = "0.18.1"
3
+ version = "0.18.3"
4
4
  edition = "2024"
5
5
  description = "A Python module implemented in Rust for serializing and deserializing RLBot's flatbuffers"
6
6
  repository = "https://github.com/RLBot/flatbuffers-python"
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: rlbot_flatbuffers
3
+ Version: 0.18.3
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ License-File: LICENSE
8
+ Summary: A Python module implemented in Rust for serializing and deserializing RLBot's flatbuffers
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
11
+ Project-URL: Source Code, https://github.com/RLBot/flatbuffers-python
12
+
13
+ ## rlbot-flatbuffers
14
+
15
+ A Python module implemented in Rust for fast and safe serialization and deserialization of RLBot's flatbuffers
16
+
17
+ ### The goal of this project
18
+
19
+ A majority of the code is auto-generated by `codegen/` upon first compile
20
+ using the RLBot's schema as defined by the `flatbuffers-schema` submodule.
21
+
22
+ This includes the code generated by Planus (`src/planus_flat.rs`),
23
+ the Python wrapper binds to the generated Rust code (`src/python/`),
24
+ and the Python type hints (`rlbot_flatbuffers.pyi`).
25
+
26
+ Usage of this API should not significantly differ from RLBot v4 to reduce developer confusion, while not holding back changes that would make the API easier to work with.
27
+
28
+ ### Minimum support Python version
29
+
30
+ The crate used to generate Python binds (PyO3) supports all the way back to Python 3.7, however the minimum supported Python version is 3.10 for a few reasons:
31
+
32
+ 1. RLBot v4 currently runs Python 3.11
33
+ 1. The RLBot v5's [Python interface](https://github.com/RLBot/python-interface) has a minimum Python version of 3.11, but the difference between 3.10 and 3.11 doesn't mean much for these binds specifically.
34
+ 1. Python 3.10 is the version of Python that added `match`/`case`
35
+ 1. [Python 3.7 & 3.8 are EOL, with 3.9's EOL date being 2025-10](https://devguide.python.org/versions/)
36
+
37
+ ### Dev setup
38
+
39
+ - Ensure Python 3.10+ is installed
40
+ - Create a virtual Python environment
41
+ - `python3 -m venv venv`
42
+ - Activate the virtual environment
43
+ - Windows: `venv\Scripts\activate.bat`
44
+ - Linux: `source venv/bin/activate`
45
+ - Install maturin
46
+ - `pip install maturin`
47
+ - Build & install for testing
48
+ - `maturin develop --release`
49
+
50
+ To use in another Python environment, like if testing [python-interface](https://github.com/RLBot/python-interface), you can build the wheel:
51
+
52
+ - `maturin build --release`
53
+ - (In another environment) `pip install path/to/file.whl`
54
+
55
+ The exact path of the wheel will be printed by maturin, just copy+paste it.
56
+
57
+ ### Basic usage
58
+
59
+ All classes and methods should have types hints readable by your IDE, removing the guesswork of common operations.
60
+
61
+ #### Creating
62
+
63
+ ```python
64
+ import rlbot_flatbuffers as flat
65
+
66
+ desired_ball = flat.DesiredBallState(
67
+ physics=flat.Physics(
68
+ location=flat.Vector3Partial(z=200),
69
+ velocity=flat.Vector3Partial(x=1500, y=1500),
70
+ angular_velocity=flat.Vector3Partial(),
71
+ ),
72
+ )
73
+
74
+ desired_game_info = flat.DesiredGameInfoState(
75
+ world_gravity_z=-100,
76
+ game_speed=2,
77
+ )
78
+
79
+ desired_game_state = flat.DesiredGameState(
80
+ ball_state=desired_ball,
81
+ game_info_state=desired_game_info,
82
+ )
83
+ ```
84
+
85
+ In the above code, we:
86
+
87
+ - Set the ball to:
88
+ - Location (0, 0, 200)
89
+ - Velocity (1500, 1500, 0)
90
+ - Angular velocity of (0, 0, 0)
91
+ - Don't set the car states
92
+ - Set the game info state:
93
+ - World gravity to -100
94
+ - Game speed to 2x default
95
+ - Don't set end match or paused
96
+ - Don't set any console commands
97
+
98
+ All values are optional when creating a class and have the proper defaults.
99
+
100
+ #### Reading values
101
+
102
+ ```python
103
+ import rlbot_flatbuffers as flat
104
+
105
+ def handle_packet(packet: flat.GamePacket):
106
+ if packet.match_info.match_phase not in {
107
+ flat.MatchPhase.Active,
108
+ flat.MatchPhase.Kickoff,
109
+ }:
110
+ # Return early if the game isn't active
111
+ return
112
+
113
+ # Print the ball's location
114
+ print(packet.ball.physics.location)
115
+
116
+ for car in packet.players:
117
+ # Print the every car's location
118
+ print(car.physics.location)
119
+ ```
120
+
121
+ The goal of the above was to feel familiar to RLBot v4 while providing a more Pythonic interface.
122
+
123
+ - Unions aren't custom types, rather a normal Python variable that can be 1 of a few types.
124
+ - For example, previously [`BallInfo.shape` had the separate type `CollisionShape` which contained the union's data](https://github.com/RLBot/RLBot/blob/e34dd4598bc643e2b8e50b77f7ffe4ca38e335de/src/main/python/rlbot/utils/structures/game_data_struct.pyi#L65-L95) but the type is now just `BoxShape | CylinderShape | SphereShape`
125
+
126
+ - Classes implement `__match_args__` for easy destructuring via the `match`/`case` pattern.
127
+ - Enums can still be used to match against the type,
128
+ they just can't be destructured.
129
+ - Classes and enums properly implement `__repr__`, with `__str__` being an alias.
130
+ - Enums implement `__hash__`, `__int__` and `__eq__`.
131
+ - Lists no longer have `num_x` fields accompanying them,
132
+ they are just Python lists of the appropriate length.
133
+ - Classes implement `pack` and `unpack`,
134
+ which are used to serialize and deserialize data.
135
+ - These are public methods that can be used directly for any purpose,
136
+ for example saving `flat.GamePacket` to a file.
137
+
138
+ - Auto-generated python type stub (`.pyi`) generation that includes doc comments from the Flatbuffers schema
139
+
@@ -277,7 +277,7 @@ fn main() -> eyre::Result<()> {
277
277
  fs::write(OUT_FILE, format_string(&generated_planus)?.as_bytes())?;
278
278
 
279
279
  class_inject::classes_to_lib_rs(class_names)?;
280
- pyi::generator(&declarations.declarations)?;
280
+ pyi::generator(&declarations)?;
281
281
 
282
282
  Ok(())
283
283
  }
@@ -1,8 +1,8 @@
1
1
  use crate::{enums::normalize_caps, structs::DEFAULT_OVERRIDES};
2
- use indexmap::IndexMap;
2
+ use indexmap::IndexSet;
3
3
  use planus_types::{
4
4
  ast::IntegerType,
5
- intermediate::{AbsolutePath, AssignMode, Declaration, DeclarationKind, SimpleType, TypeKind},
5
+ intermediate::{AssignMode, DeclarationKind, Declarations, SimpleType, TypeKind},
6
6
  };
7
7
  use std::{borrow::Cow, fs, io};
8
8
 
@@ -18,7 +18,7 @@ macro_rules! write_fmt {
18
18
  };
19
19
  }
20
20
 
21
- pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<()> {
21
+ pub fn generator(type_data: &Declarations) -> io::Result<()> {
22
22
  let mut file = vec![
23
23
  Cow::Borrowed("from __future__ import annotations"),
24
24
  Cow::Borrowed(""),
@@ -31,10 +31,15 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
31
31
  Cow::Borrowed(""),
32
32
  ];
33
33
 
34
- let mut sorted_types: Vec<_> = type_data.iter().collect();
35
- sorted_types.sort_by(|(a, _), (b, _)| a.0.last().unwrap().cmp(b.0.last().unwrap()));
34
+ let sorted_types: IndexSet<usize> = type_data
35
+ .children
36
+ .iter()
37
+ .chain(&type_data.parents)
38
+ .flat_map(|v| v.iter().map(|ty| ty.0))
39
+ .collect();
36
40
 
37
- for (full_type_name, item) in sorted_types {
41
+ for idx in sorted_types {
42
+ let (full_type_name, item) = type_data.declarations.get_index(idx).unwrap();
38
43
  if matches!(item.kind, DeclarationKind::Union(_)) {
39
44
  continue;
40
45
  }
@@ -56,26 +61,28 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
56
61
  match &item.kind {
57
62
  DeclarationKind::Enum(info) => {
58
63
  for (var_val, var_info) in &info.variants {
59
- write_fmt!(
60
- file,
61
- " {} = {type_name}({var_val})",
62
- normalize_caps(&var_info.name)
63
- );
64
+ write_fmt!(file, " {}: {type_name}", normalize_caps(&var_info.name));
65
+
66
+ write_str!(file, " \"\"\"");
67
+ write_fmt!(file, " self.value = {var_val}");
64
68
 
65
69
  if !var_info.docstrings.docstrings.is_empty() {
66
- write_str!(file, " \"\"\"");
70
+ write_str!(file, "");
67
71
 
68
72
  for line in &var_info.docstrings.docstrings {
69
73
  write_fmt!(file, " {}", line.value.trim());
70
74
  }
71
-
72
- write_str!(file, " \"\"\"");
73
75
  }
76
+
77
+ write_str!(file, " \"\"\"");
74
78
  }
75
79
 
76
80
  write_str!(file, "");
77
- write_str!(file, " def __new__(cls, value: int = 0): ...");
78
- write_str!(file, " def __init__(self, value: int = 0):");
81
+ write_fmt!(
82
+ file,
83
+ " def __new__(cls, value: int = 0) -> {type_name}: ..."
84
+ );
85
+ write_str!(file, " def __init__(self, value: int = 0) -> None:");
79
86
  write_str!(file, " \"\"\"");
80
87
  write_str!(
81
88
  file,
@@ -93,11 +100,11 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
93
100
  SimpleType::Float(_) => "float",
94
101
  SimpleType::Integer(_) => "int",
95
102
  SimpleType::Enum(idx) => {
96
- let (path, _) = type_data.get_index(idx.0).unwrap();
103
+ let (path, _) = type_data.declarations.get_index(idx.0).unwrap();
97
104
  path.0.last().unwrap()
98
105
  }
99
106
  SimpleType::Struct(idx) => {
100
- let (path, _) = type_data.get_index(idx.0).unwrap();
107
+ let (path, _) = type_data.declarations.get_index(idx.0).unwrap();
101
108
  path.0.last().unwrap()
102
109
  }
103
110
  });
@@ -116,8 +123,8 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
116
123
  }
117
124
 
118
125
  if info.fields.is_empty() {
119
- write_str!(file, " def __new__(cls): ...");
120
- write_str!(file, " def __init__(self): ...\n");
126
+ write_fmt!(file, " def __new__(cls) -> {type_name}: ...");
127
+ write_str!(file, " def __init__(self) -> None: ...\n");
121
128
  continue;
122
129
  }
123
130
 
@@ -130,7 +137,7 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
130
137
  write_str!(file, " )");
131
138
  write_str!(file, "");
132
139
 
133
- let inits = [("new", "cls"), ("init", "self")];
140
+ let inits = [("new", "cls", type_name.as_str()), ("init", "self", "None")];
134
141
 
135
142
  let default_overrides: Vec<_> = DEFAULT_OVERRIDES
136
143
  .into_iter()
@@ -143,7 +150,7 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
143
150
  })
144
151
  .collect();
145
152
 
146
- for (func, first_arg) in inits {
153
+ for (func, first_arg, ret_type) in inits {
147
154
  write_fmt!(file, " def __{func}__(");
148
155
  write_fmt!(file, " {first_arg},");
149
156
 
@@ -153,11 +160,11 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
153
160
  SimpleType::Float(_) => "float",
154
161
  SimpleType::Integer(_) => "int",
155
162
  SimpleType::Enum(idx) => {
156
- let (path, _) = type_data.get_index(idx.0).unwrap();
163
+ let (path, _) = type_data.declarations.get_index(idx.0).unwrap();
157
164
  path.0.last().unwrap()
158
165
  }
159
166
  SimpleType::Struct(idx) => {
160
- let (path, _) = type_data.get_index(idx.0).unwrap();
167
+ let (path, _) = type_data.declarations.get_index(idx.0).unwrap();
161
168
  path.0.last().unwrap()
162
169
  }
163
170
  });
@@ -175,7 +182,7 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
175
182
  SimpleType::Float(_) => Cow::Borrowed("0.0"),
176
183
  SimpleType::Integer(_) => Cow::Borrowed("0"),
177
184
  SimpleType::Enum(idx) | SimpleType::Struct(idx) => {
178
- let (path, _) = type_data.get_index(idx.0).unwrap();
185
+ let (path, _) = type_data.declarations.get_index(idx.0).unwrap();
179
186
  let name = path.0.last().unwrap();
180
187
  Cow::Owned(format!("{name}()"))
181
188
  }
@@ -187,7 +194,7 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
187
194
  );
188
195
  }
189
196
 
190
- write_str!(file, " ): ...");
197
+ write_fmt!(file, " ) -> {ret_type}: ...");
191
198
  }
192
199
  }
193
200
  DeclarationKind::Table(info) => {
@@ -198,11 +205,11 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
198
205
  SimpleType::Float(_) => "float",
199
206
  SimpleType::Integer(_) => "int",
200
207
  SimpleType::Enum(idx) => {
201
- let (path, _) = type_data.get_index(idx.0).unwrap();
208
+ let (path, _) = type_data.declarations.get_index(idx.0).unwrap();
202
209
  path.0.last().unwrap()
203
210
  }
204
211
  SimpleType::Struct(idx) => {
205
- let (path, _) = type_data.get_index(idx.0).unwrap();
212
+ let (path, _) = type_data.declarations.get_index(idx.0).unwrap();
206
213
  match path.0.last().unwrap().as_str() {
207
214
  "Float" => "float",
208
215
  name => name,
@@ -210,7 +217,7 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
210
217
  }
211
218
  }),
212
219
  TypeKind::Union(idx) => {
213
- let (_, info) = type_data.get_index(idx.0).unwrap();
220
+ let (_, info) = type_data.declarations.get_index(idx.0).unwrap();
214
221
  let DeclarationKind::Union(union_info) = &info.kind else {
215
222
  unreachable!()
216
223
  };
@@ -221,7 +228,7 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
221
228
  Cow::Owned(keys.join(" | "))
222
229
  }
223
230
  TypeKind::Table(idx) => {
224
- let (path, _) = type_data.get_index(idx.0).unwrap();
231
+ let (path, _) = type_data.declarations.get_index(idx.0).unwrap();
225
232
  Cow::Borrowed(path.0.last().unwrap().as_str())
226
233
  }
227
234
  TypeKind::String => Cow::Borrowed("str"),
@@ -232,14 +239,15 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
232
239
  SimpleType::Integer(IntegerType::U8) => Cow::Borrowed("bytes"),
233
240
  SimpleType::Integer(_) => Cow::Borrowed("Sequence[int]"),
234
241
  SimpleType::Enum(idx) | SimpleType::Struct(idx) => {
235
- let (path, _) = type_data.get_index(idx.0).unwrap();
242
+ let (path, _) =
243
+ type_data.declarations.get_index(idx.0).unwrap();
236
244
  let name = path.0.last().unwrap().as_str();
237
245
  Cow::Owned(format!("Sequence[{name}]"))
238
246
  }
239
247
  },
240
248
  TypeKind::String => Cow::Borrowed("Sequence[str]"),
241
249
  TypeKind::Table(idx) => {
242
- let (path, _) = type_data.get_index(idx.0).unwrap();
250
+ let (path, _) = type_data.declarations.get_index(idx.0).unwrap();
243
251
  let name = path.0.last().unwrap().as_str();
244
252
  Cow::Owned(format!("Sequence[{name}]"))
245
253
  }
@@ -268,8 +276,8 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
268
276
  }
269
277
 
270
278
  if info.fields.is_empty() {
271
- write_str!(file, " def __new__(cls): ...");
272
- write_str!(file, " def __init__(self): ...\n");
279
+ write_fmt!(file, " def __new__(cls) -> {type_name}: ...");
280
+ write_str!(file, " def __init__(self) -> None: ...\n");
273
281
  continue;
274
282
  }
275
283
 
@@ -282,9 +290,9 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
282
290
  write_str!(file, " )");
283
291
  write_str!(file, "");
284
292
 
285
- let inits = [("new", "cls"), ("init", "self")];
293
+ let inits = [("new", "cls", type_name.as_str()), ("init", "self", "None")];
286
294
 
287
- for (func, first_arg) in inits {
295
+ for (func, first_arg, ret_type) in inits {
288
296
  write_fmt!(file, " def __{func}__(");
289
297
  write_fmt!(file, " {first_arg},");
290
298
 
@@ -295,11 +303,13 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
295
303
  SimpleType::Float(_) => "float",
296
304
  SimpleType::Integer(_) => "int",
297
305
  SimpleType::Enum(idx) => {
298
- let (path, _) = type_data.get_index(idx.0).unwrap();
306
+ let (path, _) =
307
+ type_data.declarations.get_index(idx.0).unwrap();
299
308
  path.0.last().unwrap()
300
309
  }
301
310
  SimpleType::Struct(idx) => {
302
- let (path, _) = type_data.get_index(idx.0).unwrap();
311
+ let (path, _) =
312
+ type_data.declarations.get_index(idx.0).unwrap();
303
313
  match path.0.last().unwrap().as_str() {
304
314
  "Float" => "float",
305
315
  name => name,
@@ -307,11 +317,11 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
307
317
  }
308
318
  }),
309
319
  TypeKind::Table(idx) => {
310
- let (path, _) = type_data.get_index(idx.0).unwrap();
320
+ let (path, _) = type_data.declarations.get_index(idx.0).unwrap();
311
321
  Cow::Borrowed(path.0.last().unwrap().as_str())
312
322
  }
313
323
  TypeKind::Union(idx) => {
314
- let (_, info) = type_data.get_index(idx.0).unwrap();
324
+ let (_, info) = type_data.declarations.get_index(idx.0).unwrap();
315
325
  let DeclarationKind::Union(union_info) = &info.kind else {
316
326
  unreachable!()
317
327
  };
@@ -330,14 +340,16 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
330
340
  SimpleType::Integer(IntegerType::U8) => Cow::Borrowed("bytes"),
331
341
  SimpleType::Integer(_) => Cow::Borrowed("Sequence[int]"),
332
342
  SimpleType::Enum(idx) | SimpleType::Struct(idx) => {
333
- let (path, _) = type_data.get_index(idx.0).unwrap();
343
+ let (path, _) =
344
+ type_data.declarations.get_index(idx.0).unwrap();
334
345
  let name = path.0.last().unwrap().as_str();
335
346
  Cow::Owned(format!("Sequence[{name}]"))
336
347
  }
337
348
  },
338
349
  TypeKind::String => Cow::Borrowed("Sequence[str]"),
339
350
  TypeKind::Table(idx) => {
340
- let (path, _) = type_data.get_index(idx.0).unwrap();
351
+ let (path, _) =
352
+ type_data.declarations.get_index(idx.0).unwrap();
341
353
  let name = path.0.last().unwrap().as_str();
342
354
  Cow::Owned(format!("Sequence[{name}]"))
343
355
  }
@@ -360,7 +372,8 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
360
372
  SimpleType::Float(_) => Cow::Borrowed("0.0"),
361
373
  SimpleType::Integer(_) => Cow::Borrowed("0"),
362
374
  SimpleType::Enum(idx) | SimpleType::Struct(idx) => {
363
- let (path, _) = type_data.get_index(idx.0).unwrap();
375
+ let (path, _) =
376
+ type_data.declarations.get_index(idx.0).unwrap();
364
377
  let name = path.0.last().unwrap();
365
378
  Cow::Owned(format!("{name}()"))
366
379
  }
@@ -373,12 +386,14 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
373
386
  _ => Cow::Borrowed("[]"),
374
387
  },
375
388
  TypeKind::Table(idx) => {
376
- let (path, _) = type_data.get_index(idx.0).unwrap();
389
+ let (path, _) =
390
+ type_data.declarations.get_index(idx.0).unwrap();
377
391
  let name = path.0.last().unwrap();
378
392
  Cow::Owned(format!("{name}()"))
379
393
  }
380
394
  TypeKind::Union(idx) => {
381
- let (_, info) = type_data.get_index(idx.0).unwrap();
395
+ let (_, info) =
396
+ type_data.declarations.get_index(idx.0).unwrap();
382
397
  let DeclarationKind::Union(union_info) = &info.kind else {
383
398
  unreachable!()
384
399
  };
@@ -398,7 +413,7 @@ pub fn generator(type_data: &IndexMap<AbsolutePath, Declaration>) -> io::Result<
398
413
  );
399
414
  }
400
415
 
401
- write_str!(file, " ): ...");
416
+ write_fmt!(file, " ) -> {ret_type}: ...");
402
417
  }
403
418
 
404
419
  write_str!(file, " def pack(self) -> bytes:");
@@ -10,7 +10,10 @@ classifiers = [
10
10
  "Programming Language :: Python :: Implementation :: CPython",
11
11
  "Programming Language :: Python :: Implementation :: PyPy",
12
12
  ]
13
- dynamic = ["version"]
13
+ dynamic = ["version", "description", "urls", "readme"]
14
14
 
15
15
  [tool.maturin]
16
16
  features = ["pyo3/extension-module", "pyo3/abi3-py310"]
17
+
18
+ [tool.ruff.lint]
19
+ ignore = ["F403", "F405"]
@@ -1,8 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: rlbot_flatbuffers
3
- Version: 0.18.1
4
- Classifier: Programming Language :: Rust
5
- Classifier: Programming Language :: Python :: Implementation :: CPython
6
- Classifier: Programming Language :: Python :: Implementation :: PyPy
7
- License-File: LICENSE
8
- Requires-Python: >=3.10