From fd8beac8fa46a2596e8e4eb8a7895e32deaa7915 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 21 Oct 2023 21:20:09 -0700 Subject: [PATCH 1/3] src/sage/misc/lazy_attribute.pyi: New --- src/sage/misc/lazy_attribute.pyi | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/sage/misc/lazy_attribute.pyi diff --git a/src/sage/misc/lazy_attribute.pyi b/src/sage/misc/lazy_attribute.pyi new file mode 100644 index 00000000000..aff688c5f57 --- /dev/null +++ b/src/sage/misc/lazy_attribute.pyi @@ -0,0 +1 @@ +lazy_attribute = property From 8281d2e26ccef6105dfbe805c8813aadb8c7af3c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 21 Oct 2023 21:38:43 -0700 Subject: [PATCH 2/3] src/sage/misc/lazy_attribute.pyi: Add comment --- src/sage/misc/lazy_attribute.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/misc/lazy_attribute.pyi b/src/sage/misc/lazy_attribute.pyi index aff688c5f57..c4a2cdc2522 100644 --- a/src/sage/misc/lazy_attribute.pyi +++ b/src/sage/misc/lazy_attribute.pyi @@ -1 +1,3 @@ +# This type-stub file helps pyright understand the decorator @lazy_attribute. + lazy_attribute = property From 5d313543f4120b7bfe1cdbcc18d8d67be4b6d291 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 22 Oct 2023 08:19:38 -0700 Subject: [PATCH 3/3] src/sage/misc/lazy_attribute.pyi: Proper type stub for lazy_attribute --- src/sage/misc/lazy_attribute.pyi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sage/misc/lazy_attribute.pyi b/src/sage/misc/lazy_attribute.pyi index c4a2cdc2522..6a174a37aa2 100644 --- a/src/sage/misc/lazy_attribute.pyi +++ b/src/sage/misc/lazy_attribute.pyi @@ -1,3 +1,9 @@ # This type-stub file helps pyright understand the decorator @lazy_attribute. -lazy_attribute = property +# Adapted from https://github.com/python/typeshed/blob/b9640005eb586afdbe0a57bac2b88a7a12465069/stdlib/builtins.pyi#L1237-L1254 +class lazy_attribute: + def __init__( + self, + f: Callable[[Any], Any] | None = ... + ) -> None: ... + def __get__(self, a: Any, cls: type) -> Any: ...