-
-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stub out a brain for stdlib
datetime
- Loading branch information
1 parent
bfc9c4b
commit 8c87d6e
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html | ||
# For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE | ||
# Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt | ||
|
||
import textwrap | ||
|
||
from astroid.brain.helpers import register_module_extender | ||
from astroid.builder import AstroidBuilder | ||
from astroid.const import PY312_PLUS | ||
from astroid.manager import AstroidManager | ||
|
||
|
||
def datetime_transform(): | ||
"""The datetime module was C-accelerated in Python 3.12, so we | ||
lack a Python source.""" | ||
return AstroidBuilder(AstroidManager()).string_build( | ||
textwrap.dedent( | ||
""" | ||
class date: ... | ||
class time: ... | ||
class datetime(date): ... | ||
class timedelta: ... | ||
class tzinfo: ... | ||
class timezone(tzinfo): ... | ||
""" | ||
) | ||
) | ||
|
||
|
||
if PY312_PLUS: | ||
register_module_extender(AstroidManager(), "datetime", datetime_transform) |