-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize Python to better differentiate between pub and internals. (#…
…677)
- Loading branch information
1 parent
5589ad7
commit b31a090
Showing
10 changed files
with
83 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
#![forbid(unused_lifetimes)] | ||
#![forbid(elided_lifetimes_in_paths)] | ||
|
||
use pyo3::{pymodule, types::PyModule, Bound, PyResult, Python}; | ||
use pyo3::{ | ||
pymodule, | ||
types::{PyModule, PyModuleMethods}, | ||
Bound, PyResult, Python, | ||
}; | ||
|
||
pub mod errors; | ||
pub mod shim; | ||
mod value; | ||
|
||
#[pymodule] | ||
fn trustfall(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { | ||
fn _trustfall_internal(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { | ||
shim::register(py, m)?; | ||
errors::register(py, m)?; | ||
Ok(()) | ||
} | ||
|
||
#[pymodule] | ||
fn trustfall(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { | ||
let submodule = PyModule::new_bound(py, "_trustfall_internal")?; | ||
_trustfall_internal(py, &submodule)?; | ||
m.add_submodule(&submodule) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from . import trustfall | ||
|
||
# Workaround around issue preventing direct `from ._trustfall_internal import X` imports: | ||
# https://github.com/PyO3/pyo3/issues/759 | ||
# https://github.com/PyO3/pyo3/issues/1517 | ||
_trustfall_internal = trustfall._trustfall_internal | ||
AdapterShim = _trustfall_internal.AdapterShim | ||
Schema = _trustfall_internal.Schema | ||
FrontendError = _trustfall_internal.FrontendError | ||
InvalidIRQueryError = _trustfall_internal.InvalidIRQueryError | ||
InvalidSchemaError = _trustfall_internal.InvalidSchemaError | ||
ParseError = _trustfall_internal.ParseError | ||
QueryArgumentsError = _trustfall_internal.QueryArgumentsError | ||
ValidationError = _trustfall_internal.ValidationError | ||
interpret_query = _trustfall_internal.interpret_query | ||
|
||
__all__ = [ | ||
"AdapterShim", | ||
"FrontendError", | ||
"InvalidIRQueryError", | ||
"InvalidSchemaError", | ||
"ParseError", | ||
"QueryArgumentsError", | ||
"Schema", | ||
"ValidationError", | ||
"interpret_query", | ||
] |
10 changes: 6 additions & 4 deletions
10
pytrustfall/trustfall/trustfall.pyi → pytrustfall/trustfall/_internals.pyi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import unittest | ||
|
||
from ..trustfall import ( | ||
from .. import ( | ||
InvalidSchemaError, | ||
Schema, | ||
) | ||
|