Skip to content

Commit 5ae1aec

Browse files
authored
Reduce Python API surface area to what is necessary for kcl.py (#4637)
Signed-off-by: Nick Cameron <[email protected]>
1 parent 68ae7e9 commit 5ae1aec

File tree

6 files changed

+8
-17
lines changed

6 files changed

+8
-17
lines changed

src/wasm-lib/kcl/src/ast/modify.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ use kcmc::{
66
};
77
use kittycad_modeling_cmds as kcmc;
88

9-
use super::types::Node;
109
use crate::{
1110
ast::types::{
12-
ArrayExpression, CallExpression, ConstraintLevel, FormatOptions, Literal, PipeExpression, PipeSubstitution,
13-
VariableDeclarator,
11+
ArrayExpression, CallExpression, ConstraintLevel, FormatOptions, Literal, Node, PipeExpression,
12+
PipeSubstitution, VariableDeclarator,
1413
},
1514
engine::EngineManager,
1615
errors::{KclError, KclErrorDetails},

src/wasm-lib/kcl/src/ast/types.rs

-2
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ impl Program {
541541
/// #!/usr/bin/env python
542542
/// ```
543543
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, ts_rs::TS, JsonSchema, Bake)]
544-
#[cfg_attr(feature = "pyo3", pyo3::pyclass)]
545544
#[databake(path = kcl_lib::ast::types)]
546545
#[ts(export)]
547546
pub struct Shebang {
@@ -2936,7 +2935,6 @@ pub enum Hover {
29362935

29372936
/// Format options.
29382937
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
2939-
#[cfg_attr(feature = "pyo3", pyo3::pyclass)]
29402938
#[ts(export)]
29412939
#[serde(rename_all = "camelCase")]
29422940
pub struct FormatOptions {

src/wasm-lib/kcl/src/executor.rs

-1
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,6 @@ pub enum BodyType {
991991
/// Info about a module. Right now, this is pretty minimal. We hope to cache
992992
/// modules here in the future.
993993
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize, ts_rs::TS, JsonSchema)]
994-
#[cfg_attr(feature = "pyo3", pyo3::pyclass)]
995994
#[ts(export)]
996995
pub struct ModuleInfo {
997996
/// The ID of the module.

src/wasm-lib/kcl/src/lint/rule.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ where
3030
#[serde(rename_all = "camelCase")]
3131
pub struct Discovered {
3232
/// Zoo Lint Finding information.
33-
pub finding: Finding,
33+
pub(super) finding: Finding,
3434

3535
/// Further information about the specific finding.
36-
pub description: String,
36+
pub(super) description: String,
3737

3838
/// Source code location.
39-
pub pos: SourceRange,
39+
pub(super) pos: SourceRange,
4040

4141
/// Is this discovered issue overridden by the programmer?
42-
pub overridden: bool,
42+
pub(super) overridden: bool,
4343
}
4444

4545
#[cfg(feature = "pyo3")]
@@ -56,8 +56,8 @@ impl Discovered {
5656
}
5757

5858
#[getter]
59-
pub fn pos(&self) -> SourceRange {
60-
self.pos
59+
pub fn pos(&self) -> (usize, usize) {
60+
(self.pos.start(), self.pos.end())
6161
}
6262

6363
#[getter]

src/wasm-lib/kcl/src/source_range.rs

-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use tower_lsp::lsp_types::{Position as LspPosition, Range as LspRange};
55

66
/// Identifier of a source file. Uses a u32 to keep the size small.
77
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize, ts_rs::TS, JsonSchema, Bake)]
8-
#[cfg_attr(feature = "pyo3", pyo3::pyclass)]
98
#[databake(path = kcl_lib::ast::types)]
109
#[ts(export)]
1110
pub struct ModuleId(u32);
@@ -26,9 +25,7 @@ impl ModuleId {
2625
}
2726
}
2827

29-
// TODO Serialization and Python bindings expose the implementation of source ranges.
3028
#[derive(Debug, Default, Deserialize, Serialize, PartialEq, Copy, Clone, ts_rs::TS, JsonSchema, Hash, Eq)]
31-
#[cfg_attr(feature = "pyo3", pyo3::pyclass)]
3229
#[ts(export, as = "TsSourceRange")]
3330
pub struct SourceRange([usize; 3]);
3431

src/wasm-lib/kcl/src/token.rs

-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub(crate) use tokeniser::RESERVED_WORDS;
2222

2323
/// The types of tokens.
2424
#[derive(Debug, PartialEq, Eq, Copy, Clone, Deserialize, Serialize, JsonSchema, FromStr, Display)]
25-
#[cfg_attr(feature = "pyo3", pyo3::pyclass(eq, eq_int))]
2625
#[serde(rename_all = "camelCase")]
2726
#[display(style = "camelCase")]
2827
pub enum TokenType {
@@ -159,7 +158,6 @@ impl TokenType {
159158
}
160159

161160
#[derive(Debug, PartialEq, Eq, Deserialize, Serialize, Clone)]
162-
#[cfg_attr(feature = "pyo3", pyo3::pyclass)]
163161
pub struct Token {
164162
#[serde(rename = "type")]
165163
pub token_type: TokenType,

0 commit comments

Comments
 (0)