11#!/usr/bin/env python
22
3- # Copyright 2016 - 2021 Alexey Stepanov aka penguinolog
3+ # Copyright 2016 - 2022 Alexey Stepanov aka penguinolog
44# Licensed under the Apache License, Version 2.0 (the "License"); you may
55# not use this file except in compliance with the License. You may obtain
66# a copy of the License at
2020# Standard Library
2121import typing
2222
23+ if typing .TYPE_CHECKING :
24+ # Standard Library
25+ from collections .abc import Callable
26+
2327__all__ = ("AdvancedProperty" ,)
2428
2529_OwnerClassT = typing .TypeVar ("_OwnerClassT" )
@@ -121,27 +125,27 @@ class AdvancedProperty(property, typing.Generic[_OwnerClassT, _ReturnT, _ClassRe
121125
122126 def __init__ (
123127 self ,
124- fget : typing . Callable [[_OwnerClassT ], _ReturnT ] | None = None ,
125- fset : typing . Callable [[_OwnerClassT , _ReturnT ], None ] | None = None ,
126- fdel : typing . Callable [[_OwnerClassT ], None ] | None = None ,
127- fcget : typing . Callable [[type [_OwnerClassT ]], _ClassReturnT ] | None = None ,
128+ fget : Callable [[_OwnerClassT ], _ReturnT ] | None = None ,
129+ fset : Callable [[_OwnerClassT , _ReturnT ], None ] | None = None ,
130+ fdel : Callable [[_OwnerClassT ], None ] | None = None ,
131+ fcget : Callable [[type [_OwnerClassT ]], _ClassReturnT ] | None = None ,
128132 ) -> None :
129133 """Advanced property main entry point.
130134
131135 :param fget: normal getter.
132- :type fget: typing. Callable[[typing.Any, ], typing.Any] | None
136+ :type fget: Callable[[typing.Any, ], typing.Any] | None
133137 :param fset: normal setter.
134- :type fset: typing. Callable[[typing.Any, typing.Any], None] | None
138+ :type fset: Callable[[typing.Any, typing.Any], None] | None
135139 :param fdel: normal deleter.
136- :type fdel: typing. Callable[[typing.Any, ], None] | None
140+ :type fdel: Callable[[typing.Any, ], None] | None
137141 :param fcget: class getter. Used as normal, if normal is None.
138- :type fcget: typing. Callable[[typing.Any, ], typing.Any] | None
142+ :type fcget: Callable[[typing.Any, ], typing.Any] | None
139143
140144 .. note:: doc argument is not supported due to class wide getter usage.
141145 """
142146 super ().__init__ (fget = fget , fset = fset , fdel = fdel )
143147
144- self .__fcget : typing . Callable [[type [_OwnerClassT ]], _ClassReturnT ] | None = fcget
148+ self .__fcget : Callable [[type [_OwnerClassT ]], _ClassReturnT ] | None = fcget
145149
146150 @typing .overload
147151 def __get__ (self , instance : None , owner : type [_OwnerClassT ]) -> _ClassReturnT :
@@ -159,7 +163,7 @@ def __get__(
159163 """Get descriptor.
160164
161165 :param instance: Owner class instance. Filled only if instance created, else None.
162- :type instance: typing.Optional[ owner]
166+ :type instance: owner | None
163167 :param owner: Owner class for property.
164168 :return: getter call result if getter presents
165169 :rtype: typing.Any
@@ -172,22 +176,22 @@ def __get__(
172176 return super ().__get__ (instance , owner ) # type: ignore[no-any-return]
173177
174178 @property
175- def fcget (self ) -> typing . Callable [[type [_OwnerClassT ]], _ClassReturnT ] | None :
179+ def fcget (self ) -> Callable [[type [_OwnerClassT ]], _ClassReturnT ] | None :
176180 """Class wide getter instance.
177181
178182 :return: Class wide getter instance
179- :rtype: typing. Callable[[typing.Any, ], typing.Any] | None
183+ :rtype: Callable[[typing.Any, ], typing.Any] | None
180184 """
181185 return self .__fcget
182186
183187 def cgetter (
184188 self ,
185- fcget : typing . Callable [[type [_OwnerClassT ]], _ClassReturnT ] | None ,
189+ fcget : Callable [[type [_OwnerClassT ]], _ClassReturnT ] | None ,
186190 ) -> AdvancedProperty [_OwnerClassT , _ReturnT , _ClassReturnT ]:
187191 """Descriptor to change the class wide getter on a property.
188192
189193 :param fcget: new class-wide getter.
190- :type fcget: typing. Callable[[typing.Any, ], typing.Any] | None
194+ :type fcget: Callable[[typing.Any, ], typing.Any] | None
191195 :return: AdvancedProperty
192196 :rtype: AdvancedProperty
193197 """
0 commit comments