1
0
Fork 0

Merging upstream version 26.26.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-06-11 08:06:17 +02:00
parent 768f936511
commit 1ac9fca060
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
62 changed files with 938 additions and 453 deletions

View file

@ -1,7 +1,7 @@
use crate::settings::TokenType;
use pyo3::prelude::*;
use pyo3::types::{PyList, PyString};
use pyo3::{pyclass, Py, PyObject, Python};
use pyo3::{pyclass, pymethods, Py, PyObject, Python};
#[derive(Debug)]
#[pyclass]
@ -57,3 +57,25 @@ impl Token {
});
}
}
#[pymethods]
impl Token {
fn __repr__(&self, py: Python) -> PyResult<String> {
let text = self.text.bind(py).to_str()?;
let comments = self.comments.bind(py);
let token_type_str = self.token_type_py.bind(py).str()?;
let comments_repr = comments.repr()?;
let comments_str = comments_repr.to_str()?;
Ok(format!(
"<Token token_type: {}, text: {}, line: {}, col: {}, start: {}, end: {}, comments: {}>",
token_type_str,
text,
self.line,
self.col,
self.start,
self.end,
comments_str
))
}
}