File tree 1 file changed +31
-0
lines changed 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
2
+ # For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE
3
+ # Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt
4
+
5
+ import textwrap
6
+
7
+ from astroid .brain .helpers import register_module_extender
8
+ from astroid .builder import AstroidBuilder
9
+ from astroid .const import PY312_PLUS
10
+ from astroid .manager import AstroidManager
11
+
12
+
13
+ def datetime_transform ():
14
+ """The datetime module was C-accelerated in Python 3.12, so we
15
+ lack a Python source."""
16
+ return AstroidBuilder (AstroidManager ()).string_build (
17
+ textwrap .dedent (
18
+ """
19
+ class date: ...
20
+ class time: ...
21
+ class datetime(date): ...
22
+ class timedelta: ...
23
+ class tzinfo: ...
24
+ class timezone(tzinfo): ...
25
+ """
26
+ )
27
+ )
28
+
29
+
30
+ if PY312_PLUS :
31
+ register_module_extender (AstroidManager (), "datetime" , datetime_transform )
You can’t perform that action at this time.
0 commit comments