mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
typevar as module (#6834)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -13,12 +13,11 @@ pub fn init(ctx: &Context) {
|
||||
NoDefault::extend_class(ctx, ctx.types.typing_no_default_type);
|
||||
}
|
||||
|
||||
#[pymodule(name = "_typing")]
|
||||
#[pymodule(name = "_typing", with(super::typevar::typevar))]
|
||||
pub(crate) mod decl {
|
||||
use crate::{
|
||||
Py, PyObjectRef, PyPayload, PyResult, VirtualMachine,
|
||||
builtins::{PyStrRef, PyTupleRef, PyType, PyTypeRef, pystr::AsPyStr, type_},
|
||||
class::PyClassImpl,
|
||||
function::{FuncArgs, IntoFuncArgs},
|
||||
protocol::PyNumberMethods,
|
||||
types::{AsNumber, Constructor, Representable},
|
||||
@@ -176,41 +175,14 @@ pub(crate) mod decl {
|
||||
}
|
||||
}
|
||||
|
||||
// impl AsMapping for Generic {
|
||||
// fn as_mapping() -> &'static PyMappingMethods {
|
||||
// static AS_MAPPING: Lazy<PyMappingMethods> = Lazy::new(|| PyMappingMethods {
|
||||
// subscript: atomic_func!(|mapping, needle, vm| {
|
||||
// call_typing_func_object(vm, "_GenericAlias", (mapping.obj, needle))
|
||||
// }),
|
||||
// ..PyMappingMethods::NOT_IMPLEMENTED
|
||||
// });
|
||||
// &AS_MAPPING
|
||||
// }
|
||||
// }
|
||||
|
||||
pub(crate) fn module_exec(
|
||||
vm: &VirtualMachine,
|
||||
module: &Py<crate::builtins::PyModule>,
|
||||
) -> PyResult<()> {
|
||||
__module_exec(vm, module);
|
||||
|
||||
use super::{Generic, ParamSpec, ParamSpecArgs, ParamSpecKwargs, TypeVar, TypeVarTuple};
|
||||
|
||||
TypeVar::make_class(&vm.ctx);
|
||||
ParamSpec::make_class(&vm.ctx);
|
||||
TypeVarTuple::make_class(&vm.ctx);
|
||||
ParamSpecArgs::make_class(&vm.ctx);
|
||||
ParamSpecKwargs::make_class(&vm.ctx);
|
||||
Generic::make_class(&vm.ctx);
|
||||
|
||||
extend_module!(vm, module, {
|
||||
"NoDefault" => vm.ctx.typing_no_default.clone(),
|
||||
"TypeVar" => TypeVar::class(&vm.ctx).to_owned(),
|
||||
"ParamSpec" => ParamSpec::class(&vm.ctx).to_owned(),
|
||||
"TypeVarTuple" => TypeVarTuple::class(&vm.ctx).to_owned(),
|
||||
"ParamSpecArgs" => ParamSpecArgs::class(&vm.ctx).to_owned(),
|
||||
"ParamSpecKwargs" => ParamSpecKwargs::class(&vm.ctx).to_owned(),
|
||||
"Generic" => Generic::class(&vm.ctx).to_owned(),
|
||||
"Union" => vm.ctx.types.union_type.to_owned(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user