예제 #1
0
import wrapt
from astroid import bases
from astroid import context as contextmod
from astroid import exceptions
from astroid import decorators
from astroid import helpers
from astroid import manager
from astroid import nodes
from astroid.interpreter import dunder_lookup
from astroid import protocols
from astroid import util

MANAGER = manager.AstroidManager()
# Prevents circular imports
objects = util.lazy_import("objects")

# .infer method ###############################################################


def infer_end(self, context=None):
    """Inference's end for nodes that yield themselves on inference

    These are objects for which inference does not have any semantic,
    such as Module or Consts.
    """
    yield self


nodes.Module._infer = infer_end
nodes.ClassDef._infer = infer_end
예제 #2
0
from astroid.const import PY310_PLUS
from astroid.context import (
    CallContext,
    InferenceContext,
    bind_context_to_node,
    copy_context,
)
from astroid.exceptions import (
    AstroidTypeError,
    AttributeInferenceError,
    InferenceError,
    NameInferenceError,
)
from astroid.util import Uninferable, lazy_descriptor, lazy_import

objectmodel = lazy_import("interpreter.objectmodel")
helpers = lazy_import("helpers")
manager = lazy_import("manager")

# TODO: check if needs special treatment
BOOL_SPECIAL_METHOD = "__bool__"
BUILTINS = "builtins"  # TODO Remove in 2.8

PROPERTIES = {"builtins.property", "abc.abstractproperty"}
if PY310_PLUS:
    PROPERTIES.add("enum.property")

# List of possible property names. We use this list in order
# to see if a method is a property or not. This should be
# pretty reliable and fast, the alternative being to check each
# decorator to see if its a real property-like descriptor, which
예제 #3
0
파일: objects.py 프로젝트: hnegus1/UWE_DSP
    Call(func=Name('frozenset'), args=Tuple(...))
"""

import builtins

from astroid import bases
from astroid import decorators
from astroid import exceptions
from astroid import MANAGER
from astroid import node_classes
from astroid import scoped_nodes
from astroid import util

BUILTINS = builtins.__name__
objectmodel = util.lazy_import("interpreter.objectmodel")


class FrozenSet(node_classes._BaseContainer):
    """class representing a FrozenSet composite node"""
    def pytype(self):
        return "%s.frozenset" % BUILTINS

    def _infer(self, context=None):
        yield self

    @decorators.cachedproperty
    def _proxied(self):  # pylint: disable=method-hidden
        ast_builtins = MANAGER.builtins_module
        return ast_builtins.getattr("frozenset")[0]
예제 #4
0
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
# For details: https://github.com/PyCQA/astroid/blob/master/COPYING.LESSER
"""This module contains base classes and functions for the nodes and some
inference utils.
"""

import collections
import sys

import six

from astroid import context as contextmod
from astroid import exceptions
from astroid import util

objectmodel = util.lazy_import('interpreter.objectmodel')
BUILTINS = six.moves.builtins.__name__
manager = util.lazy_import('manager')
MANAGER = manager.AstroidManager()

if sys.version_info >= (3, 0):
    BUILTINS = 'builtins'
    BOOL_SPECIAL_METHOD = '__bool__'
else:
    BUILTINS = '__builtin__'
    BOOL_SPECIAL_METHOD = '__nonzero__'
PROPERTIES = {BUILTINS + '.property', 'abc.abstractproperty'}
# List of possible property names. We use this list in order
# to see if a method is a property or not. This should be
# pretty reliable and fast, the alternative being to check each
# decorator to see if its a real property-like descriptor, which
예제 #5
0
import operator as operator_mod
import sys

import six

from astroid import arguments
from astroid import bases
from astroid import context as contextmod
from astroid import exceptions
from astroid import decorators
from astroid import node_classes
from astroid import helpers
from astroid import nodes
from astroid import util

raw_building = util.lazy_import('raw_building')
objects = util.lazy_import('objects')


def _reflected_name(name):
    return "__r" + name[2:]


def _augmented_name(name):
    return "__i" + name[2:]


_CONTEXTLIB_MGR = 'contextlib.contextmanager'
BIN_OP_METHOD = {
    '+': '__add__',
    '-': '__sub__',
예제 #6
0
import collections
import operator as operator_mod
import sys

from astroid import Store
from astroid import arguments
from astroid import bases
from astroid import context as contextmod
from astroid import exceptions
from astroid import decorators
from astroid import node_classes
from astroid import helpers
from astroid import nodes
from astroid import util

raw_building = util.lazy_import('raw_building')
objects = util.lazy_import('objects')

def _reflected_name(name):
    return "__r" + name[2:]

def _augmented_name(name):
    return "__i" + name[2:]


_CONTEXTLIB_MGR = 'contextlib.contextmanager'
BIN_OP_METHOD = {'+':  '__add__',
                 '-':  '__sub__',
                 '/':  '__truediv__',
                 '//': '__floordiv__',
                 '*':  '__mul__',
예제 #7
0
import sys

import itertools

from astroid import Store
from astroid import arguments
from astroid import bases
from astroid import context as contextmod
from astroid import exceptions
from astroid import decorators
from astroid import node_classes
from astroid import helpers
from astroid import nodes
from astroid import util

raw_building = util.lazy_import("raw_building")
objects = util.lazy_import("objects")


def _reflected_name(name):
    return "__r" + name[2:]


def _augmented_name(name):
    return "__i" + name[2:]


_CONTEXTLIB_MGR = "contextlib.contextmanager"
BIN_OP_METHOD = {
    "+": "__add__",
    "-": "__sub__",
예제 #8
0
import sys

import itertools

from astroid import Store
from astroid import arguments
from astroid import bases
from astroid import context as contextmod
from astroid import exceptions
from astroid import decorators
from astroid import node_classes
from astroid import helpers
from astroid import nodes
from astroid import util

raw_building = util.lazy_import("raw_building")
objects = util.lazy_import("objects")


def _reflected_name(name):
    return "__r" + name[2:]


def _augmented_name(name):
    return "__i" + name[2:]


_CONTEXTLIB_MGR = "contextlib.contextmanager"
BIN_OP_METHOD = {
    "+": "__add__",
    "-": "__sub__",
예제 #9
0
파일: objects.py 프로젝트: ahmo10/problem
    Call(func=Name('frozenset'), args=Tuple(...))
"""

import builtins

from astroid import bases
from astroid import decorators
from astroid import exceptions
from astroid import MANAGER
from astroid import node_classes
from astroid import scoped_nodes
from astroid import util

BUILTINS = builtins.__name__
objectmodel = util.lazy_import('interpreter.objectmodel')


class FrozenSet(node_classes._BaseContainer):
    """class representing a FrozenSet composite node"""
    def pytype(self):
        return '%s.frozenset' % BUILTINS

    def _infer(self, context=None):
        yield self

    @decorators.cachedproperty
    def _proxied(self):  # pylint: disable=method-hidden
        ast_builtins = MANAGER.astroid_cache[BUILTINS]
        return ast_builtins.getattr('frozenset')[0]
예제 #10
0
import itertools
import os
import pprint
import sys
import types
from functools import lru_cache
from typing import TYPE_CHECKING, Any

import astroid
from astroid import bases, nodes, util
from astroid.context import InferenceContext, copy_context
from astroid.exceptions import AttributeInferenceError, InferenceError, NoDefault
from astroid.manager import AstroidManager
from astroid.nodes import node_classes

objects = util.lazy_import("objects")
builder = util.lazy_import("builder")

if sys.version_info >= (3, 8):
    from typing import Literal
else:
    from typing_extensions import Literal

if TYPE_CHECKING:
    from astroid import builder
    from astroid.objects import Property

IMPL_PREFIX = "attr_"
LEN_OF_IMPL_PREFIX = len(IMPL_PREFIX)

예제 #11
0
파일: bases.py 프로젝트: gtt116/vimrc
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
# For details: https://github.com/PyCQA/astroid/blob/master/COPYING.LESSER

"""This module contains base classes and functions for the nodes and some
inference utils.
"""

import builtins
import collections
import sys

from astroid import context as contextmod
from astroid import exceptions
from astroid import util

objectmodel = util.lazy_import('interpreter.objectmodel')
helpers = util.lazy_import('helpers')
BUILTINS = builtins.__name__
manager = util.lazy_import('manager')
MANAGER = manager.AstroidManager()

if sys.version_info >= (3, 0):
    # TODO: check if needs special treatment
    BUILTINS = 'builtins'
    BOOL_SPECIAL_METHOD = '__bool__'
else:
    BUILTINS = '__builtin__'
    BOOL_SPECIAL_METHOD = '__nonzero__'
PROPERTIES = {BUILTINS + '.property', 'abc.abstractproperty'}
# List of possible property names. We use this list in order
# to see if a method is a property or not. This should be
예제 #12
0
파일: objects.py 프로젝트: my88899/astroid
    Call(func=Name('frozenset'), args=Tuple(...))
"""

import six

from astroid import bases
from astroid import decorators
from astroid import exceptions
from astroid import MANAGER
from astroid import node_classes
from astroid import scoped_nodes
from astroid import util


BUILTINS = six.moves.builtins.__name__
objectmodel = util.lazy_import('interpreter.objectmodel')


class FrozenSet(node_classes._BaseContainer):
    """class representing a FrozenSet composite node"""

    def pytype(self):
        return '%s.frozenset' % BUILTINS

    def _infer(self, context=None):
        yield self

    @decorators.cachedproperty
    def _proxied(self): # pylint: disable=method-hidden
        builtins = MANAGER.astroid_cache[BUILTINS]
        return builtins.getattr('frozenset')[0]
예제 #13
0
    Call(func=Name('frozenset'), args=Tuple(...))
"""

import builtins

from astroid import bases
from astroid import decorators
from astroid import exceptions
from astroid import MANAGER
from astroid import node_classes
from astroid import scoped_nodes
from astroid import util


BUILTINS = builtins.__name__
objectmodel = util.lazy_import("interpreter.objectmodel")


class FrozenSet(node_classes._BaseContainer):
    """class representing a FrozenSet composite node"""

    def pytype(self):
        return "%s.frozenset" % BUILTINS

    def _infer(self, context=None):
        yield self

    @decorators.cachedproperty
    def _proxied(self):  # pylint: disable=method-hidden
        ast_builtins = MANAGER.astroid_cache[BUILTINS]
        return ast_builtins.getattr("frozenset")[0]
예제 #14
0
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
# For details: https://github.com/PyCQA/astroid/blob/master/COPYING.LESSER

"""This module contains base classes and functions for the nodes and some
inference utils.
"""

import builtins
import collections
import sys

from astroid import context as contextmod
from astroid import exceptions
from astroid import util

objectmodel = util.lazy_import("interpreter.objectmodel")
helpers = util.lazy_import("helpers")
BUILTINS = builtins.__name__
manager = util.lazy_import("manager")
MANAGER = manager.AstroidManager()

if sys.version_info >= (3, 0):
    # TODO: check if needs special treatment
    BUILTINS = "builtins"
    BOOL_SPECIAL_METHOD = "__bool__"
else:
    BUILTINS = "__builtin__"
    BOOL_SPECIAL_METHOD = "__nonzero__"
PROPERTIES = {BUILTINS + ".property", "abc.abstractproperty"}
# List of possible property names. We use this list in order
# to see if a method is a property or not. This should be