Allow parsing source code directly#54
Conversation
|
Thanks for the PR! Me or Jukka will try to take a look next week. In the meantime, could you please resolve the merge conflict? |
| match pyo3::exceptions::PyUnicodeDecodeError::new_utf8( | ||
| obj.py(), | ||
| e.as_bytes(), | ||
| utf8_err, | ||
| ) { | ||
| Ok(err) => Self::Error::from_value(err.into_any()), | ||
| Err(err) => err, | ||
| } |
There was a problem hiding this comment.
Implementation taken from https://pyo3.rs/main/doc/src/pyo3/exceptions.rs#802-811 (PR https://github.com/PyO3/pyo3/pull/5668/changes), because new_err_from_utf8 is only in pyo3 0.29 which is not released yet.
The test is here: python/mypy@ac275e4
| )> { | ||
| serialize_module( | ||
| source, | ||
| PySourceType::Python, |
There was a problem hiding this comment.
I've hard-coded Python source type here, because mypy parsing functions never previously exposed an option to let the user treat source code directly as a .pyi stub source.
|
Hmm...there might be some unnecessary allocations that are preventable. I'm going to do some benchmarking with another implementation. |
|
If we're willing to use Performance of |
Resolves #21
Tests are part of python/mypy#21260