Both the true Python backend and the Python PEP 484 Type Stub backend have
    to perform the same imports.

    :param insert_type_ignore: add a MyPy type-ignore comment to the imports in
        the except: clause.
9569
def generate_imports_for_referenced_namespaces(
        backend, namespace, insert_type_ignore=False):
    # type: (Backend, ApiNamespace, bool) -> None
    

    imported_namespaces = namespace.get_imported_namespaces(consider_annotation_types=True)
    if not imported_namespaces:
        return

    type_ignore_comment = TYPE_IGNORE_COMMENT if insert_type_ignore else ""

    backend.emit('try:')
    with backend.indent():
        backend.emit('from . import (')
        with backend.indent():
            for ns in imported_namespaces:
                backend.emit(fmt_namespace(ns.name) + ',')
        backend.emit(')')
    backend.emit('except (ImportError, SystemError, ValueError):')
    # Fallback if imported from outside a package.
    with backend.indent():
        for ns in imported_namespaces:
            backend.emit('import {namespace_name}{type_ignore_comment}'.format(
                namespace_name=fmt_namespace(ns.name),
                type_ignore_comment=type_ignore_comment
            ))
    backend.emit()
1330194
public static <T extends Content> IgnoringPrompt<T> create(ContentType type, SendableMessage promptMessage) {
        return new IgnoringPrompt<>(type, promptMessage);
    }
699019
def database_add_types(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/addTypes' % object_id, input_params, always_retry=always_retry, **kwargs)
1233255
protected String buildInsertSQL(final TableMetadata metadata, final Class<? extends Object> type,
			final SqlConfig sqlConfig, final boolean ignoreWhenEmpty) {
		Map<String, MappingColumn> mappingColumns = MappingUtils.getMappingColumnMap(type, SqlKind.INSERT);
		StringBuilder sql = buildInsertTargetBlock(metadata, mappingColumns, sqlConfig, ignoreWhenEmpty);
		sql.append(" VALUES ");
		sql.append(buildInsertRowBlock(metadata, mappingColumns, sqlConfig, ignoreWhenEmpty,
				TableMetadata.Column::getCamelColumnName));
		return sql.toString();
	}
1062307
def insert(self, bs, pos=None):
        
        bs = Bits(bs)
        if not bs.len:
            return self
        if bs is self:
            bs = self.__copy__()
        if pos is None:
            try:
                pos = self._pos
            except AttributeError:
                raise TypeError("insert require a bit position for this type.")
        if pos < 0:
            pos += self.len
        if not 0 <= pos <= self.len:
            raise ValueError("Invalid insert position.")
        self._insert(bs, pos)
1228624
String createInsertPreparedSQLStatement(D6Inex includeExcludeColumnNames,boolean ignoreDuplicate) {

        final Set<String> columnNameSet = getAllColumnNames();

        final StringGrabber sgSQL = new StringGrabber();

        // Get the table name
        final DBTable table = mModelClazz.getAnnotation(DBTable.class);
        final String tableName = table.tableName();

        if(ignoreDuplicate){
        	sgSQL.append("INSERT IGNORE INTO " + tableName + " (");
        }else{
        sgSQL.append("INSERT INTO " + tableName + " (");
        }
        final StringGrabber sgColumnNames = new StringGrabber();
        final StringGrabber sgValues = new StringGrabber();

        if (includeExcludeColumnNames != null) {
            includeExcludeColumnNames.manipulate(columnNameSet);
        }

        for (String columnName : columnNameSet) {

            final D6ModelClassFieldInfo fieldInfo = getFieldInfo(columnName);

            //
            final boolean isAutoIncrement = fieldInfo.isAutoIncrement;

            if (isAutoIncrement == false) {
                // - if auto increment is off
                sgColumnNames.append(columnName);
                sgColumnNames.append(", ");
                sgValues.append("?");
                sgValues.append(", ");
            } else {
                // - if auto increment is available
                // it's not the target of the update
            }

        }// end for

        if (sgColumnNames.length() > 2) {
            sgColumnNames.removeTail(2);
        }
        if (sgValues.length() > 2) {
            sgValues.removeTail(2);
        }

        sgSQL.append(sgColumnNames.toString());
        sgSQL.append(") ");
        sgSQL.append("VALUES ( ");
        sgSQL.append(sgValues.toString());
        sgSQL.append(" )");

        final String sql = sgSQL.toString();

        log("#createInsertPreparedSQLStatement sql=" + sql);

        return sql;
    }
823478
def _Insert(cursor, table, values):
  
  precondition.AssertIterableType(values, dict)

  if not values:  # Nothing can be INSERTed with empty `values` list.
    return

  column_names = list(sorted(values[0]))
  for value_dict in values:
    if set(column_names) != set(value_dict):
      raise ValueError("Given value dictionaries must have identical keys. "
                       "Expecting columns {!r}, but got value {!r}".format(
                           column_names, value_dict))

  query = "INSERT IGNORE INTO %s {cols} VALUES {vals}" % table
  query = query.format(
      cols=mysql_utils.Columns(column_names),
      vals=mysql_utils.Placeholders(num=len(column_names), values=len(values)))

  values_list = []
  for values_dict in values:
    values_list.extend(values_dict[column] for column in column_names)

  cursor.execute(query, values_list)
63759
def add(self, type):
        # type: (InternalType) -> None
        
        try:
            if isinstance(type, SetType):
                if EMPTY_SET_TYPE in self.types_hashable:
                    self.types_hashable.remove(EMPTY_SET_TYPE)
            elif isinstance(type, ListType):
                if EMPTY_LIST_TYPE in self.types_hashable:
                    self.types_hashable.remove(EMPTY_LIST_TYPE)
            elif isinstance(type, IteratorType):
                if EMPTY_ITERATOR_TYPE in self.types_hashable:
                    self.types_hashable.remove(EMPTY_ITERATOR_TYPE)
            elif isinstance(type, DictType):
                if EMPTY_DICT_TYPE in self.types_hashable:
                    self.types_hashable.remove(EMPTY_DICT_TYPE)
                for item in self.types_hashable:
                    if isinstance(item, DictType):
                        if item.key_type == type.key_type:
                            item.val_type.merge(type.val_type)
                            return
            self.types_hashable.add(type)

        except (TypeError, AttributeError):
            try:
                if type not in self.types:
                    self.types.append(type)
            except AttributeError:
                if TypeWasIncomparable not in self.types:
                    self.types.append(TypeWasIncomparable)
88459
def parse_type(defn, preprocess=True):
    
    if pycparser is None:
        raise ImportError("Please install pycparser in order to parse C definitions")

    defn = 'typedef ' + defn.strip('; \n\t\r') + ' QQQQ;'

    if preprocess:
        defn = do_preprocess(defn)

    node = pycparser.c_parser.CParser().parse(make_preamble()[0] + defn)
    if not isinstance(node, pycparser.c_ast.FileAST) or \
            not isinstance(node.ext[-1], pycparser.c_ast.Typedef):
        raise ValueError("Something went horribly wrong using pycparser")

    decl = node.ext[-1].type
    return _decl_to_type(decl)
1338088
def insert(self, table, records, create_cols=False, dtypes=None):
        
        if self._check_db() is False:
            return
        try:
            table = self.db[table]
        except Exception as e:
            self.err(e, "Can not find table " + table)
        t = type(records)
        if t == dict:
            func = table.insert
        elif t == list:
            func = table.insert_many
        else:
            msg = "Rows datatype " + \
                str(t) + " not valid: use a list or a dictionary"
            self.err(msg)
        if create_cols is True:
            try:
                func(records, ensure=True, types=dtypes)
            except Exception as e:
                self.err(e, "Can not insert create columns and insert data")
            return
        else:
            try:
                func(records, types=dtypes)
            except Exception as e:
                self.err(e, "Can not insert data")
            return
        self.ok("Rows inserted in the database")
306384
def _appendBPoint(self, type, anchor, bcpIn=None, bcpOut=None, **kwargs):
        
        self.insertBPoint(
            len(self.bPoints),
            type,
            anchor,
            bcpIn=bcpIn,
            bcpOut=bcpOut
        )
546320
def _coerce_dtype(self, other_dtype):
        
        if self._dtype is None:
            new_dtype = np.dtype(other_dtype)
        else:
            new_dtype = np.find_common_type([self._dtype, np.dtype(other_dtype)], [])
        if new_dtype != self.dtype:
            self.set_dtype(new_dtype)
25128
def _init_ugly_crap():
    
    import ctypes
    from types import TracebackType

    # figure out side of _Py_ssize_t
    if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
        _Py_ssize_t = ctypes.c_int64
    else:
        _Py_ssize_t = ctypes.c_int

    # regular python
    class _PyObject(ctypes.Structure):
        pass
    _PyObject._fields_ = [
        ('ob_refcnt', _Py_ssize_t),
        ('ob_type', ctypes.POINTER(_PyObject))
    ]

    # python with trace
    if object.__basicsize__ != ctypes.sizeof(_PyObject):
        class _PyObject(ctypes.Structure):
            pass
        _PyObject._fields_ = [
            ('_ob_next', ctypes.POINTER(_PyObject)),
            ('_ob_prev', ctypes.POINTER(_PyObject)),
            ('ob_refcnt', _Py_ssize_t),
            ('ob_type', ctypes.POINTER(_PyObject))
        ]

    class _Traceback(_PyObject):
        pass
    _Traceback._fields_ = [
        ('tb_next', ctypes.POINTER(_Traceback)),
        ('tb_frame', ctypes.POINTER(_PyObject)),
        ('tb_lasti', ctypes.c_int),
        ('tb_lineno', ctypes.c_int)
    ]

    def tb_set_next(tb, next):
        """Set the tb_next attribute of a traceback object."""
        if not (isinstance(tb, TracebackType) and
                (next is None or isinstance(next, TracebackType))):
            raise TypeError('tb_set_next arguments must be traceback objects')
        obj = _Traceback.from_address(id(tb))
        if tb.tb_next is not None:
            old = _Traceback.from_address(id(tb.tb_next))
            old.ob_refcnt -= 1
        if next is None:
            obj.tb_next = ctypes.POINTER(_Traceback)()
        else:
            next = _Traceback.from_address(id(next))
            next.ob_refcnt += 1
            obj.tb_next = ctypes.pointer(next)

    return tb_set_next
478479
def _reorder_types(self, types_script):
        
        self._logger.debug('Running types definitions scripts')
        self._logger.debug('Reordering types definitions scripts to avoid "type does not exist" exceptions')
        _type_statements = sqlparse.split(types_script)
        # TODO: move up to classes
        _type_statements_dict = {}  # dictionary that store statements with type and order.
        type_unordered_scripts = []  # scripts to execute without order
        type_drop_scripts = []  # drop scripts to execute first
        for _type_statement in _type_statements:
            _type_statement_parsed = sqlparse.parse(_type_statement)
            if len(_type_statement_parsed) > 0:  # can be empty parsed object so need to check
                # we need only type declarations to be ordered
                if _type_statement_parsed[0].get_type() == 'CREATE':
                    _type_body_r = r'\bcreate\s+\b(?:type|domain)\s+\b(\w+\.\w+|\w+)\b'
                    _type_name = re.compile(_type_body_r, flags=re.IGNORECASE).findall(_type_statement)[0]
                    _type_statements_dict[str(_type_name)] = \
                        {'script': _type_statement, 'deps': []}
                elif _type_statement_parsed[0].get_type() == 'DROP':
                    type_drop_scripts.append(_type_statement)
                else:
                    type_unordered_scripts.append(_type_statement)
        # now let's add dependant types to dictionary with types
        # _type_statements_list = []  # list of statements to be ordered
        for _type_key in _type_statements_dict.keys():
            for _type_key_sub, _type_value in _type_statements_dict.items():
                if _type_key != _type_key_sub:
                    if pgpm.lib.utils.misc.find_whole_word(_type_key)(_type_value['script']):
                        _type_value['deps'].append(_type_key)
        # now let's add order to type scripts and put them ordered to list
        _deps_unresolved = True
        _type_script_order = 0
        _type_names = []
        type_ordered_scripts = []  # ordered list with scripts to execute
        while _deps_unresolved:
            for k, v in _type_statements_dict.items():
                if not v['deps']:
                    _type_names.append(k)
                    v['order'] = _type_script_order
                    _type_script_order += 1
                    if not v['script'] in type_ordered_scripts:
                        type_ordered_scripts.append(v['script'])
                else:
                    _dep_exists = True
                    for _dep in v['deps']:
                        if _dep not in _type_names:
                            _dep_exists = False
                    if _dep_exists:
                        _type_names.append(k)
                        v['order'] = _type_script_order
                        _type_script_order += 1
                        if not v['script'] in type_ordered_scripts:
                            type_ordered_scripts.append(v['script'])
                    else:
                        v['order'] = -1
            _deps_unresolved = False
            for k, v in _type_statements_dict.items():
                if v['order'] == -1:
                    _deps_unresolved = True
        return type_drop_scripts, type_ordered_scripts, type_unordered_scripts
84822
def filter_traceback(error, tb, ignore_pkg=CURRENT_PACKAGE):
    
    if not isinstance(tb, types.TracebackType):
        return tb

    def in_namespace(n):
        return n and (n.startswith(ignore_pkg + '.') or n == ignore_pkg)
    # Skip test runner traceback levels
    while tb and in_namespace(tb.tb_frame.f_globals['__package__']):
        tb = tb.tb_next
    starting_tb = tb
    limit = 0
    while tb and not in_namespace(tb.tb_frame.f_globals['__package__']):
        tb = tb.tb_next
        limit += 1

    return ''.join(traceback.format_exception(error.__class__, error, starting_tb, limit))
439109
def insert(self, schema, fields, **kwargs):
        
        r = 0

        with self.connection(**kwargs) as connection:
            kwargs['connection'] = connection
            try:
                with self.transaction(**kwargs):
                    r = self._insert(schema, fields, **kwargs)

            except Exception as e:
                exc_info = sys.exc_info()
                if self.handle_error(schema, e, **kwargs):
                    r = self._insert(schema, fields, **kwargs)
                else:
                    self.raise_error(e, exc_info)

        return r
1006273
def _import_type(line: str) -> Optional[str]:
        """"""
        if "isort:skip" in line or "NOQA" in line:
            return None
        elif line.startswith('import '):
            return "straight"
        elif line.startswith('from '):
            return "from"