Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/astroid/brain/brain_decimal.py: 67%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

12 statements  

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 

5from astroid import nodes 

6from astroid.brain.helpers import register_module_extender 

7from astroid.builder import AstroidBuilder 

8from astroid.manager import AstroidManager 

9 

10 

11def decimal_transform() -> nodes.Module: 

12 """The _decimal module is not always available and the _pydecimal fallback can't be inferred.""" 

13 return AstroidBuilder(AstroidManager()).string_build("from _pydecimal import *") 

14 

15 

16def register(manager: AstroidManager) -> None: 

17 try: 

18 import _decimal # pylint: disable=unused-import,import-outside-toplevel 

19 except ImportError: 

20 register_module_extender(manager, "decimal", decimal_transform)