Skip to content

Commit ec5899b

Browse files
Stub out a brain for stdlib datetime
1 parent a7e7455 commit ec5899b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

astroid/brain/brain_datetime.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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)

0 commit comments

Comments
 (0)