Routine to validate that typ is a valid non-empty PEP484 type hint. If it is a forward reference, it will be 
    resolved 
    
    :param typ: 
    :param item_type: 
    :param attr_name: 
    :return:
7739
def get_validated_attribute_type_info(typ, item_type, attr_name):
    
    if (typ is None) or (typ is Parameter.empty):
        raise TypeInformationRequiredError.create_for_object_attributes(item_type, attr_name, typ)

    # resolve forward references
    typ = resolve_forward_ref(typ)

    if not is_valid_pep484_type_hint(typ):
        raise InvalidPEP484TypeHint.create_for_object_attributes(item_type, attr_name, typ)

    return typ
1160864
private static boolean hasValidSubscriptionType(RosterPacket.Item item) {
        switch (item.getItemType()) {
            case none:
            case from:
            case to:
            case both:
                return true;
            default:
                return false;
        }
    }
1114392
private String getTypeName(ElementDefinition.TypeRefComponent typ) {
    // TODO: This is brittle. There has to be a utility to do this...
    if (typ.hasTargetProfile()) {
      String[] els = typ.getTargetProfile().get(0).getValue().split("/");
      return els[els.length - 1];
    } else if (typ.hasProfile()) {
      String[] els = typ.getProfile().get(0).getValue().split("/");
      return els[els.length - 1];
    } else {
      return typ.getCode();
    }
  }
750607
def check_typ(helper, typ):
    
    if typ != "tcp" and typ != "udp":
        helper.exit(summary="Type (-t) must be udp or tcp.", exit_code=unknown, perfdata='')
814365
def valid_param_supplied_as_text?
      tag_def = @bbtree.current_node.definition

      # this conditional ensures whether the validation is apropriate to this tag type
      if @ti.element_is_text? and within_open_tag? and tag_def[:require_between] and use_text_as_parameter? and not tag_def[:quick_param_format].nil?

        # check if valid
        if @ti[:text].match(tag_def[:quick_param_format]).nil?
          add_tag_error tag_def[:quick_param_format_description].gsub('%param%', @ti[:text])
          return false
        end
      end
      true
    end
195752
def _handle_fundamental_types(self, typ):
        
        ctypesname = self.get_ctypes_name(typ.kind)
        if typ.kind == TypeKind.VOID:
            size = align = 1
        else:
            size = typ.get_size()
            align = typ.get_align()
        return typedesc.FundamentalType(ctypesname, size, align)
1072089
def types_validation!(value)
      raise ValidationError if types && types.none? { |type| type === value }
    end
567202
def _validate(item):
        """"""
        if not isinstance(item, tuple) or len(item) != 2:
            raise ValueError('Linked items must be instance/prop-name tuple')
        if not isinstance(item[0], tuple(LINK_OBSERVERS)):
            raise ValueError('Only {} instances may be linked'.format(
                ', '.join([link_cls.__name__ for link_cls in LINK_OBSERVERS])
            ))
        if not isinstance(item[1], string_types):
            raise ValueError('Properties must be specified as string names')
        if not hasattr(item[0], item[1]):
            raise ValueError('Invalid property {} for {} instance'.format(
                item[1], item[0].__class__.__name__
            ))
634740
def is_valid_package_name(name, raise_error=False):
    
    is_valid = PACKAGE_NAME_REGEX.match(name)
    if raise_error and not is_valid:
        raise PackageRequestError("Not a valid package name: %r" % name)
    return is_valid
1108369
def p_ex_list_item_id(self, p):
        ''
        p[0] = AstExampleRef(self.path, p.lineno(1), p.lexpos(1), p[1])
335982
def oftype(self, typ):
        ''''''
        for key, val in self.items():
            if val.type == typ:
                yield key
224380
def validate_attr_name(name):
    

    try:
        validate_sqlite_attr_name(name)
    except (InvalidCharError, InvalidReservedNameError) as e:
        raise NameValidationError(e)
    except NullNameError:
        raise NameValidationError("attribute name is empty")
1179229
def convert_type(ty, default=None):
    
    if isinstance(ty, tuple):
        return Tuple(ty)
    if isinstance(ty, ParamType):
        return ty
    guessed_type = False
    if ty is None and default is not None:
        ty = type(default)
        guessed_type = True
    if ty is text_type or ty is str or ty is None:
        return STRING
    if ty is int:
        return INT
    # Booleans are only okay if not guessed.  This is done because for
    # flags the default value is actually a bit of a lie in that it
    # indicates which of the flags is the one we want.  See get_default()
    # for more information.
    if ty is bool and not guessed_type:
        return BOOL
    if ty is float:
        return FLOAT
    if guessed_type:
        return STRING

    # Catch a common mistake
    if __debug__:
        try:
            if issubclass(ty, ParamType):
                raise AssertionError('Attempted to use an uninstantiated '
                                     'parameter type (%s).' % ty)
        except TypeError:
            pass
    return FuncParamType(ty)
368693
def valid_params?(name, size)
      return raise TypeError.new("A 'name' should be a string") if name.class != String
      return raise TypeError.new("A 'size' should be an integer") if size.class != Integer

      true
    end
1228331
def itemTypeWithSomeAttributes(attributeTypes):
    
    class SomeItem(Item):
        typeName = 'someitem_' + str(typeNameCounter())
        for i, attributeType in enumerate(attributeTypes):
            locals()['attr_' + str(i)] = attributeType()
    return SomeItem
825137
def _validate(self):
        
        if self.region_type not in regions_attributes:
            raise ValueError("'{0}' is not a valid region type in this package"
                             .format(self.region_type))

        if self.coordsys not in valid_coordsys['DS9'] + valid_coordsys['CRTF']:
            raise ValueError("'{0}' is not a valid coordinate reference frame "
                             "in astropy".format(self.coordsys))
997780
def is_pep484_nonable(typ):
    
    # TODO rely on typing_inspect if there is an answer to https://github.com/ilevkivskyi/typing_inspect/issues/14
    if typ is type(None):
        return True
    elif is_typevar(typ) or is_union_type(typ):
        return any(is_pep484_nonable(tt) for tt in get_alternate_types_resolving_forwardref_union_and_typevar(typ))
    else:
        return False