File tree Expand file tree Collapse file tree 2 files changed +4
-17
lines changed Expand file tree Collapse file tree 2 files changed +4
-17
lines changed Original file line number Diff line number Diff line change 2
2
# For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE
3
3
# Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt
4
4
5
- import textwrap
6
-
7
5
from astroid .brain .helpers import register_module_extender
8
6
from astroid .builder import AstroidBuilder
9
7
from astroid .const import PY312_PLUS
10
8
from astroid .manager import AstroidManager
11
9
12
10
13
11
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
- )
12
+ """The datetime module was C-accelerated in Python 3.12, so use the
13
+ Python source."""
14
+ return AstroidBuilder (AstroidManager ()).string_build ("from _pydatetime import *" )
28
15
29
16
30
17
if PY312_PLUS :
Original file line number Diff line number Diff line change @@ -26,4 +26,4 @@ def test_parser(self):
26
26
"""
27
27
)
28
28
d_type = next (module ["d" ].infer ())
29
- self .assertEqual (d_type .qname (), " datetime.datetime" )
29
+ self .assertIn (d_type .qname (), { "_pydatetime. datetime" , "datetime .datetime"} )
You can’t perform that action at this time.
0 commit comments