nwo
stringlengths
10
28
sha
stringlengths
40
40
path
stringlengths
11
97
identifier
stringlengths
1
64
parameters
stringlengths
2
2.24k
return_statement
stringlengths
0
2.17k
docstring
stringlengths
0
5.45k
docstring_summary
stringlengths
0
3.83k
func_begin
int64
1
13.4k
func_end
int64
2
13.4k
function
stringlengths
28
56.4k
url
stringlengths
106
209
project
int64
1
48
executed_lines
list
executed_lines_pc
float64
0
153
missing_lines
list
missing_lines_pc
float64
0
100
covered
bool
2 classes
filecoverage
float64
2.53
100
function_lines
int64
2
1.46k
mccabe
int64
1
253
coverage
float64
0
100
docstring_lines
int64
0
112
function_nodoc
stringlengths
9
56.4k
id
int64
0
29.8k
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/field.py
source_resolver
(source, root, info, **args)
return resolved
16
20
def source_resolver(source, root, info, **args): resolved = default_resolver(source, None, root, info, **args) if inspect.isfunction(resolved) or inspect.ismethod(resolved): return resolved() return resolved
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/field.py#L16-L20
30
[ 0 ]
20
[ 1, 2, 3, 4 ]
80
false
78
5
3
20
0
def source_resolver(source, root, info, **args): resolved = default_resolver(source, None, root, info, **args) if inspect.isfunction(resolved) or inspect.ismethod(resolved): return resolved() return resolved
20,813
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/field.py
Field.__init__
( self, type_, args=None, resolver=None, source=None, deprecation_reason=None, name=None, description=None, required=False, _creation_counter=None, default_value=None, **extra_args, )
66
112
def __init__( self, type_, args=None, resolver=None, source=None, deprecation_reason=None, name=None, description=None, required=False, _creation_counter=None, default_value=None, **extra_args, ): super(Field, self).__init__(_creation_counter=_creation_counter) assert not args or isinstance( args, Mapping ), f'Arguments in a field have to be a mapping, received "{args}".' assert not ( source and resolver ), "A Field cannot have a source and a resolver in at the same time." assert not callable( default_value ), f'The default value can not be a function but received "{base_type(default_value)}".' if required: type_ = NonNull(type_) # Check if name is actually an argument of the field if isinstance(name, (Argument, UnmountedType)): extra_args["name"] = name name = None # Check if source is actually an argument of the field if isinstance(source, (Argument, UnmountedType)): extra_args["source"] = source source = None self.name = name self._type = type_ self.args = to_arguments(args or {}, extra_args) if source: resolver = partial(source_resolver, source) self.resolver = resolver self.deprecation_reason = deprecation_reason self.description = description self.default_value = default_value
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/field.py#L66-L112
30
[ 0, 14, 15, 18, 21, 24, 25, 26, 27, 28, 29, 33, 34, 37, 38, 39, 40, 41, 43, 44, 45, 46 ]
46.808511
[ 30, 31, 35, 36, 42 ]
10.638298
false
78
47
11
89.361702
0
def __init__( self, type_, args=None, resolver=None, source=None, deprecation_reason=None, name=None, description=None, required=False, _creation_counter=None, default_value=None, **extra_args, ): super(Field, self).__init__(_creation_counter=_creation_counter) assert not args or isinstance( args, Mapping ), f'Arguments in a field have to be a mapping, received "{args}".' assert not ( source and resolver ), "A Field cannot have a source and a resolver in at the same time." assert not callable( default_value ), f'The default value can not be a function but received "{base_type(default_value)}".' if required: type_ = NonNull(type_) # Check if name is actually an argument of the field if isinstance(name, (Argument, UnmountedType)): extra_args["name"] = name name = None # Check if source is actually an argument of the field if isinstance(source, (Argument, UnmountedType)): extra_args["source"] = source source = None self.name = name self._type = type_ self.args = to_arguments(args or {}, extra_args) if source: resolver = partial(source_resolver, source) self.resolver = resolver self.deprecation_reason = deprecation_reason self.description = description self.default_value = default_value
20,814
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/field.py
Field.type
(self)
return get_type(self._type)
115
116
def type(self): return get_type(self._type)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/field.py#L115-L116
30
[ 0, 1 ]
100
[]
0
true
78
2
1
100
0
def type(self): return get_type(self._type)
20,815
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/field.py
Field.wrap_resolve
(self, parent_resolver)
return self.resolver or parent_resolver
Wraps a function resolver, using the ObjectType resolve_{FIELD_NAME} (parent_resolver) if the Field definition has no resolver.
Wraps a function resolver, using the ObjectType resolve_{FIELD_NAME} (parent_resolver) if the Field definition has no resolver.
120
131
def wrap_resolve(self, parent_resolver): """ Wraps a function resolver, using the ObjectType resolve_{FIELD_NAME} (parent_resolver) if the Field definition has no resolver. """ if self.get_resolver is not None: warn_deprecation( "The get_resolver method is being deprecated, please rename it to wrap_resolve." ) return self.get_resolver(parent_resolver) return self.resolver or parent_resolver
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/field.py#L120-L131
30
[ 0, 1, 2, 3, 4, 5, 10, 11 ]
66.666667
[ 6, 9 ]
16.666667
false
78
12
3
83.333333
2
def wrap_resolve(self, parent_resolver): if self.get_resolver is not None: warn_deprecation( "The get_resolver method is being deprecated, please rename it to wrap_resolve." ) return self.get_resolver(parent_resolver) return self.resolver or parent_resolver
20,816
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/field.py
Field.wrap_subscribe
(self, parent_subscribe)
return parent_subscribe
Wraps a function subscribe, using the ObjectType subscribe_{FIELD_NAME} (parent_subscribe) if the Field definition has no subscribe.
Wraps a function subscribe, using the ObjectType subscribe_{FIELD_NAME} (parent_subscribe) if the Field definition has no subscribe.
133
138
def wrap_subscribe(self, parent_subscribe): """ Wraps a function subscribe, using the ObjectType subscribe_{FIELD_NAME} (parent_subscribe) if the Field definition has no subscribe. """ return parent_subscribe
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/field.py#L133-L138
30
[ 0, 1, 2, 3, 4, 5 ]
100
[]
0
true
78
6
1
100
2
def wrap_subscribe(self, parent_subscribe): return parent_subscribe
20,817
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/objecttype.py
ObjectTypeMeta.__new__
(cls, name_, bases, namespace, **options)
return base_cls
22
49
def __new__(cls, name_, bases, namespace, **options): # Note: it's safe to pass options as keyword arguments as they are still type-checked by ObjectTypeOptions. # We create this type, to then overload it with the dataclass attrs class InterObjectType: pass base_cls = super().__new__( cls, name_, (InterObjectType,) + bases, namespace, **options ) if base_cls._meta: fields = [ ( key, "typing.Any", field( default=field_value.default_value if isinstance(field_value, Field) else None ), ) for key, field_value in base_cls._meta.fields.items() ] dataclass = make_dataclass(name_, fields, bases=()) InterObjectType.__init__ = dataclass.__init__ InterObjectType.__eq__ = dataclass.__eq__ InterObjectType.__repr__ = dataclass.__repr__ return base_cls
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/objecttype.py#L22-L49
30
[ 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 23, 24, 25, 26, 27 ]
53.571429
[]
0
false
89.361702
28
3
100
0
def __new__(cls, name_, bases, namespace, **options): # Note: it's safe to pass options as keyword arguments as they are still type-checked by ObjectTypeOptions. # We create this type, to then overload it with the dataclass attrs class InterObjectType: pass base_cls = super().__new__( cls, name_, (InterObjectType,) + bases, namespace, **options ) if base_cls._meta: fields = [ ( key, "typing.Any", field( default=field_value.default_value if isinstance(field_value, Field) else None ), ) for key, field_value in base_cls._meta.fields.items() ] dataclass = make_dataclass(name_, fields, bases=()) InterObjectType.__init__ = dataclass.__init__ InterObjectType.__eq__ = dataclass.__eq__ InterObjectType.__repr__ = dataclass.__repr__ return base_cls
20,818
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/objecttype.py
ObjectType.__init_subclass_with_meta__
( cls, interfaces=(), possible_types=(), default_resolver=None, _meta=None, **options, )
125
158
def __init_subclass_with_meta__( cls, interfaces=(), possible_types=(), default_resolver=None, _meta=None, **options, ): if not _meta: _meta = ObjectTypeOptions(cls) fields = {} for interface in interfaces: assert issubclass( interface, Interface ), f'All interfaces of {cls.__name__} must be a subclass of Interface. Received "{interface}".' fields.update(interface._meta.fields) for base in reversed(cls.__mro__): fields.update(yank_fields_from_attrs(base.__dict__, _as=Field)) assert not (possible_types and cls.is_type_of), ( f"{cls.__name__}.Meta.possible_types will cause type collision with {cls.__name__}.is_type_of. " "Please use one or other." ) if _meta.fields: _meta.fields.update(fields) else: _meta.fields = fields if not _meta.interfaces: _meta.interfaces = interfaces _meta.possible_types = possible_types _meta.default_resolver = default_resolver super(ObjectType, cls).__init_subclass_with_meta__(_meta=_meta, **options)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/objecttype.py#L125-L158
30
[ 0, 8, 9, 10, 11, 12, 17, 18, 19, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33 ]
55.882353
[ 13, 16 ]
5.882353
false
89.361702
34
9
94.117647
0
def __init_subclass_with_meta__( cls, interfaces=(), possible_types=(), default_resolver=None, _meta=None, **options, ): if not _meta: _meta = ObjectTypeOptions(cls) fields = {} for interface in interfaces: assert issubclass( interface, Interface ), f'All interfaces of {cls.__name__} must be a subclass of Interface. Received "{interface}".' fields.update(interface._meta.fields) for base in reversed(cls.__mro__): fields.update(yank_fields_from_attrs(base.__dict__, _as=Field)) assert not (possible_types and cls.is_type_of), ( f"{cls.__name__}.Meta.possible_types will cause type collision with {cls.__name__}.is_type_of. " "Please use one or other." ) if _meta.fields: _meta.fields.update(fields) else: _meta.fields = fields if not _meta.interfaces: _meta.interfaces = interfaces _meta.possible_types = possible_types _meta.default_resolver = default_resolver super(ObjectType, cls).__init_subclass_with_meta__(_meta=_meta, **options)
20,819
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/utils.py
get_field_as
(value, _as=None)
Get type mounted
Get type mounted
9
18
def get_field_as(value, _as=None): """ Get type mounted """ if isinstance(value, MountedType): return value elif isinstance(value, UnmountedType): if _as is None: return value return _as.mounted(value)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/utils.py#L9-L18
30
[ 0, 1, 2, 3, 4, 5, 6, 7, 9 ]
90
[ 8 ]
10
false
81.25
10
4
90
1
def get_field_as(value, _as=None): if isinstance(value, MountedType): return value elif isinstance(value, UnmountedType): if _as is None: return value return _as.mounted(value)
20,820
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/utils.py
yank_fields_from_attrs
(attrs, _as=None, sort=True)
return dict(fields_with_names)
Extract all the fields in given attributes (dict) and return them ordered
Extract all the fields in given attributes (dict) and return them ordered
21
35
def yank_fields_from_attrs(attrs, _as=None, sort=True): """ Extract all the fields in given attributes (dict) and return them ordered """ fields_with_names = [] for attname, value in list(attrs.items()): field = get_field_as(value, _as) if not field: continue fields_with_names.append((attname, field)) if sort: fields_with_names = sorted(fields_with_names, key=lambda f: f[1]) return dict(fields_with_names)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/utils.py#L21-L35
30
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ]
100
[]
0
true
81.25
15
4
100
2
def yank_fields_from_attrs(attrs, _as=None, sort=True): fields_with_names = [] for attname, value in list(attrs.items()): field = get_field_as(value, _as) if not field: continue fields_with_names.append((attname, field)) if sort: fields_with_names = sorted(fields_with_names, key=lambda f: f[1]) return dict(fields_with_names)
20,821
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/utils.py
get_type
(_type)
return _type
38
43
def get_type(_type): if isinstance(_type, str): return import_string(_type) if inspect.isfunction(_type) or isinstance(_type, partial): return _type() return _type
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/utils.py#L38-L43
30
[ 0, 1, 3, 5 ]
66.666667
[ 2, 4 ]
33.333333
false
81.25
6
4
66.666667
0
def get_type(_type): if isinstance(_type, str): return import_string(_type) if inspect.isfunction(_type) or isinstance(_type, partial): return _type() return _type
20,822
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/utils.py
get_underlying_type
(_type)
return _type
Get the underlying type even if it is wrapped in structures like NonNull
Get the underlying type even if it is wrapped in structures like NonNull
46
50
def get_underlying_type(_type): """Get the underlying type even if it is wrapped in structures like NonNull""" while hasattr(_type, "of_type"): _type = _type.of_type return _type
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/utils.py#L46-L50
30
[ 0, 1 ]
40
[ 2, 3, 4 ]
60
false
81.25
5
2
40
1
def get_underlying_type(_type): while hasattr(_type, "of_type"): _type = _type.of_type return _type
20,823
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/generic.py
GenericScalar.identity
(value)
return value
25
26
def identity(value): return value
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/generic.py#L25-L26
30
[ 0, 1 ]
100
[]
0
true
56
2
1
100
0
def identity(value): return value
20,824
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/generic.py
GenericScalar.parse_literal
(ast, _variables=None)
32
49
def parse_literal(ast, _variables=None): if isinstance(ast, (StringValueNode, BooleanValueNode)): return ast.value elif isinstance(ast, IntValueNode): num = int(ast.value) if MIN_INT <= num <= MAX_INT: return num elif isinstance(ast, FloatValueNode): return float(ast.value) elif isinstance(ast, ListValueNode): return [GenericScalar.parse_literal(value) for value in ast.values] elif isinstance(ast, ObjectValueNode): return { field.name.value: GenericScalar.parse_literal(field.value) for field in ast.fields } else: return None
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/generic.py#L32-L49
30
[ 0, 1, 2 ]
16.666667
[ 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17 ]
61.111111
false
56
18
8
38.888889
0
def parse_literal(ast, _variables=None): if isinstance(ast, (StringValueNode, BooleanValueNode)): return ast.value elif isinstance(ast, IntValueNode): num = int(ast.value) if MIN_INT <= num <= MAX_INT: return num elif isinstance(ast, FloatValueNode): return float(ast.value) elif isinstance(ast, ListValueNode): return [GenericScalar.parse_literal(value) for value in ast.values] elif isinstance(ast, ObjectValueNode): return { field.name.value: GenericScalar.parse_literal(field.value) for field in ast.fields } else: return None
20,825
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/mutation.py
Mutation.__init_subclass_with_meta__
( cls, interfaces=(), resolver=None, output=None, arguments=None, _meta=None, **options, )
68
118
def __init_subclass_with_meta__( cls, interfaces=(), resolver=None, output=None, arguments=None, _meta=None, **options, ): if not _meta: _meta = MutationOptions(cls) output = output or getattr(cls, "Output", None) fields = {} for interface in interfaces: assert issubclass( interface, Interface ), f'All interfaces of {cls.__name__} must be a subclass of Interface. Received "{interface}".' fields.update(interface._meta.fields) if not output: # If output is defined, we don't need to get the fields fields = {} for base in reversed(cls.__mro__): fields.update(yank_fields_from_attrs(base.__dict__, _as=Field)) output = cls if not arguments: input_class = getattr(cls, "Arguments", None) if not input_class: input_class = getattr(cls, "Input", None) if input_class: warn_deprecation( f"Please use {cls.__name__}.Arguments instead of {cls.__name__}.Input." " Input is now only used in ClientMutationID.\n" "Read more:" " https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#mutation-input" ) arguments = props(input_class) if input_class else {} if not resolver: mutate = getattr(cls, "mutate", None) assert mutate, "All mutations must define a mutate method in it" resolver = get_unbound_function(mutate) if _meta.fields: _meta.fields.update(fields) else: _meta.fields = fields _meta.interfaces = interfaces _meta.output = output _meta.resolver = resolver _meta.arguments = arguments super(Mutation, cls).__init_subclass_with_meta__(_meta=_meta, **options)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/mutation.py#L68-L118
30
[ 0, 9, 10, 11, 12, 13, 14, 19, 20, 21, 22, 23, 24, 25, 26, 27, 36, 37, 38, 39, 40, 41, 44, 45, 46, 47, 48, 49, 50 ]
56.862745
[ 15, 18, 28, 29, 30, 42 ]
11.764706
false
84.90566
51
13
88.235294
0
def __init_subclass_with_meta__( cls, interfaces=(), resolver=None, output=None, arguments=None, _meta=None, **options, ): if not _meta: _meta = MutationOptions(cls) output = output or getattr(cls, "Output", None) fields = {} for interface in interfaces: assert issubclass( interface, Interface ), f'All interfaces of {cls.__name__} must be a subclass of Interface. Received "{interface}".' fields.update(interface._meta.fields) if not output: # If output is defined, we don't need to get the fields fields = {} for base in reversed(cls.__mro__): fields.update(yank_fields_from_attrs(base.__dict__, _as=Field)) output = cls if not arguments: input_class = getattr(cls, "Arguments", None) if not input_class: input_class = getattr(cls, "Input", None) if input_class: warn_deprecation( f"Please use {cls.__name__}.Arguments instead of {cls.__name__}.Input." " Input is now only used in ClientMutationID.\n" "Read more:" " https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#mutation-input" ) arguments = props(input_class) if input_class else {} if not resolver: mutate = getattr(cls, "mutate", None) assert mutate, "All mutations must define a mutate method in it" resolver = get_unbound_function(mutate) if _meta.fields: _meta.fields.update(fields) else: _meta.fields = fields _meta.interfaces = interfaces _meta.output = output _meta.resolver = resolver _meta.arguments = arguments super(Mutation, cls).__init_subclass_with_meta__(_meta=_meta, **options)
20,826
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/mutation.py
Mutation.Field
( cls, name=None, description=None, deprecation_reason=None, required=False )
return Field( cls._meta.output, args=cls._meta.arguments, resolver=cls._meta.resolver, name=name, description=description or cls._meta.description, deprecation_reason=deprecation_reason, required=required, )
Mount instance of mutation Field.
Mount instance of mutation Field.
121
133
def Field( cls, name=None, description=None, deprecation_reason=None, required=False ): """Mount instance of mutation Field.""" return Field( cls._meta.output, args=cls._meta.arguments, resolver=cls._meta.resolver, name=name, description=description or cls._meta.description, deprecation_reason=deprecation_reason, required=required, )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/mutation.py#L121-L133
30
[ 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]
84.615385
[]
0
false
84.90566
13
2
100
1
def Field( cls, name=None, description=None, deprecation_reason=None, required=False ): return Field( cls._meta.output, args=cls._meta.arguments, resolver=cls._meta.resolver, name=name, description=description or cls._meta.description, deprecation_reason=deprecation_reason, required=required, )
20,827
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/context.py
Context.__init__
(self, **params)
23
25
def __init__(self, **params): for key, value in params.items(): setattr(self, key, value)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/context.py#L23-L25
30
[ 0 ]
33.333333
[ 1, 2 ]
66.666667
false
50
3
2
33.333333
0
def __init__(self, **params): for key, value in params.items(): setattr(self, key, value)
20,828
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/structures.py
Structure.__init__
(self, of_type, *args, **kwargs)
11
20
def __init__(self, of_type, *args, **kwargs): super(Structure, self).__init__(*args, **kwargs) if not isinstance(of_type, Structure) and isinstance(of_type, UnmountedType): cls_name = type(self).__name__ of_type_name = type(of_type).__name__ raise Exception( f"{cls_name} could not have a mounted {of_type_name}()" f" as inner type. Try with {cls_name}({of_type_name})." ) self._of_type = of_type
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/structures.py#L11-L20
30
[ 0, 1, 2, 9 ]
40
[ 3, 4, 5 ]
30
false
75
10
3
70
0
def __init__(self, of_type, *args, **kwargs): super(Structure, self).__init__(*args, **kwargs) if not isinstance(of_type, Structure) and isinstance(of_type, UnmountedType): cls_name = type(self).__name__ of_type_name = type(of_type).__name__ raise Exception( f"{cls_name} could not have a mounted {of_type_name}()" f" as inner type. Try with {cls_name}({of_type_name})." ) self._of_type = of_type
20,829
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/structures.py
Structure.of_type
(self)
return get_type(self._of_type)
23
24
def of_type(self): return get_type(self._of_type)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/structures.py#L23-L24
30
[ 0, 1 ]
100
[]
0
true
75
2
1
100
0
def of_type(self): return get_type(self._of_type)
20,830
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/structures.py
Structure.get_type
(self)
return self
This function is called when the unmounted type (List or NonNull instance) is mounted (as a Field, InputField or Argument)
This function is called when the unmounted type (List or NonNull instance) is mounted (as a Field, InputField or Argument)
26
31
def get_type(self): """ This function is called when the unmounted type (List or NonNull instance) is mounted (as a Field, InputField or Argument) """ return self
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/structures.py#L26-L31
30
[ 0, 1, 2, 3, 4, 5 ]
100
[]
0
true
75
6
1
100
2
def get_type(self): return self
20,831
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/structures.py
List.__str__
(self)
return f"[{self.of_type}]"
51
52
def __str__(self): return f"[{self.of_type}]"
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/structures.py#L51-L52
30
[ 0 ]
50
[ 1 ]
50
false
75
2
1
50
0
def __str__(self): return f"[{self.of_type}]"
20,832
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/structures.py
List.__eq__
(self, other)
return isinstance(other, List) and ( self.of_type == other.of_type and self.args == other.args and self.kwargs == other.kwargs )
54
59
def __eq__(self, other): return isinstance(other, List) and ( self.of_type == other.of_type and self.args == other.args and self.kwargs == other.kwargs )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/structures.py#L54-L59
30
[ 0 ]
16.666667
[ 1 ]
16.666667
false
75
6
4
83.333333
0
def __eq__(self, other): return isinstance(other, List) and ( self.of_type == other.of_type and self.args == other.args and self.kwargs == other.kwargs )
20,833
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/structures.py
NonNull.__init__
(self, *args, **kwargs)
85
89
def __init__(self, *args, **kwargs): super(NonNull, self).__init__(*args, **kwargs) assert not isinstance( self._of_type, NonNull ), f"Can only create NonNull of a Nullable GraphQLType but got: {self._of_type}."
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/structures.py#L85-L89
30
[ 0, 1, 2 ]
60
[]
0
false
75
5
2
100
0
def __init__(self, *args, **kwargs): super(NonNull, self).__init__(*args, **kwargs) assert not isinstance( self._of_type, NonNull ), f"Can only create NonNull of a Nullable GraphQLType but got: {self._of_type}."
20,834
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/structures.py
NonNull.__str__
(self)
return f"{self.of_type}!"
91
92
def __str__(self): return f"{self.of_type}!"
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/structures.py#L91-L92
30
[ 0 ]
50
[ 1 ]
50
false
75
2
1
50
0
def __str__(self): return f"{self.of_type}!"
20,835
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/structures.py
NonNull.__eq__
(self, other)
return isinstance(other, NonNull) and ( self.of_type == other.of_type and self.args == other.args and self.kwargs == other.kwargs )
94
99
def __eq__(self, other): return isinstance(other, NonNull) and ( self.of_type == other.of_type and self.args == other.args and self.kwargs == other.kwargs )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/structures.py#L94-L99
30
[ 0 ]
16.666667
[ 1 ]
16.666667
false
75
6
4
83.333333
0
def __eq__(self, other): return isinstance(other, NonNull) and ( self.of_type == other.of_type and self.args == other.args and self.kwargs == other.kwargs )
20,836
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/inputfield.py
InputField.__init__
( self, type_, name=None, default_value=Undefined, deprecation_reason=None, description=None, required=False, _creation_counter=None, **extra_args, )
49
70
def __init__( self, type_, name=None, default_value=Undefined, deprecation_reason=None, description=None, required=False, _creation_counter=None, **extra_args, ): super(InputField, self).__init__(_creation_counter=_creation_counter) self.name = name if required: assert ( deprecation_reason is None ), f"InputField {name} is required, cannot deprecate it." type_ = NonNull(type_) self._type = type_ self.deprecation_reason = deprecation_reason self.default_value = default_value self.description = description
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/inputfield.py#L49-L70
30
[ 0 ]
4.545455
[ 11, 12, 13, 14, 17, 18, 19, 20, 21 ]
40.909091
false
44.444444
22
3
59.090909
0
def __init__( self, type_, name=None, default_value=Undefined, deprecation_reason=None, description=None, required=False, _creation_counter=None, **extra_args, ): super(InputField, self).__init__(_creation_counter=_creation_counter) self.name = name if required: assert ( deprecation_reason is None ), f"InputField {name} is required, cannot deprecate it." type_ = NonNull(type_) self._type = type_ self.deprecation_reason = deprecation_reason self.default_value = default_value self.description = description
20,837
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/inputfield.py
InputField.type
(self)
return get_type(self._type)
73
74
def type(self): return get_type(self._type)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/inputfield.py#L73-L74
30
[ 0 ]
50
[ 1 ]
50
false
44.444444
2
1
50
0
def type(self): return get_type(self._type)
20,838
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/decimal.py
Decimal.serialize
(dec)
return str(dec)
17
23
def serialize(dec): if isinstance(dec, str): dec = _Decimal(dec) assert isinstance( dec, _Decimal ), f'Received not compatible Decimal "{repr(dec)}"' return str(dec)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/decimal.py#L17-L23
30
[ 0 ]
14.285714
[ 1, 2, 3, 6 ]
57.142857
false
69.565217
7
3
42.857143
0
def serialize(dec): if isinstance(dec, str): dec = _Decimal(dec) assert isinstance( dec, _Decimal ), f'Received not compatible Decimal "{repr(dec)}"' return str(dec)
20,839
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/decimal.py
Decimal.parse_literal
(cls, node, _variables=None)
return Undefined
26
29
def parse_literal(cls, node, _variables=None): if isinstance(node, (StringValueNode, IntValueNode)): return cls.parse_value(node.value) return Undefined
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/decimal.py#L26-L29
30
[ 0, 1, 2 ]
75
[ 3 ]
25
false
69.565217
4
2
75
0
def parse_literal(cls, node, _variables=None): if isinstance(node, (StringValueNode, IntValueNode)): return cls.parse_value(node.value) return Undefined
20,840
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/decimal.py
Decimal.parse_value
(value)
32
36
def parse_value(value): try: return _Decimal(value) except Exception: return Undefined
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/decimal.py#L32-L36
30
[ 0, 1, 2 ]
60
[ 3, 4 ]
40
false
69.565217
5
2
60
0
def parse_value(value): try: return _Decimal(value) except Exception: return Undefined
20,841
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/unmountedtype.py
UnmountedType.__init__
(self, *args, **kwargs)
42
45
def __init__(self, *args, **kwargs): super(UnmountedType, self).__init__() self.args = args self.kwargs = kwargs
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/unmountedtype.py#L42-L45
30
[ 0, 1, 2, 3 ]
100
[]
0
true
57.142857
4
1
100
0
def __init__(self, *args, **kwargs): super(UnmountedType, self).__init__() self.args = args self.kwargs = kwargs
20,842
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/unmountedtype.py
UnmountedType.get_type
(self)
This function is called when the UnmountedType instance is mounted (as a Field, InputField or Argument)
This function is called when the UnmountedType instance is mounted (as a Field, InputField or Argument)
47
52
def get_type(self): """ This function is called when the UnmountedType instance is mounted (as a Field, InputField or Argument) """ raise NotImplementedError(f"get_type not implemented in {self}")
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/unmountedtype.py#L47-L52
30
[ 0, 1, 2, 3, 4 ]
83.333333
[ 5 ]
16.666667
false
57.142857
6
1
83.333333
2
def get_type(self): raise NotImplementedError(f"get_type not implemented in {self}")
20,843
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/unmountedtype.py
UnmountedType.mount_as
(self, _as)
return _as.mounted(self)
54
55
def mount_as(self, _as): return _as.mounted(self)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/unmountedtype.py#L54-L55
30
[ 0 ]
50
[ 1 ]
50
false
57.142857
2
1
50
0
def mount_as(self, _as): return _as.mounted(self)
20,844
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/unmountedtype.py
UnmountedType.Field
(self)
return self.mount_as(Field)
Mount the UnmountedType as Field
Mount the UnmountedType as Field
57
63
def Field(self): # noqa: N802 """ Mount the UnmountedType as Field """ from .field import Field return self.mount_as(Field)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/unmountedtype.py#L57-L63
30
[ 0, 1, 2, 3 ]
57.142857
[ 4, 6 ]
28.571429
false
57.142857
7
1
71.428571
1
def Field(self): # noqa: N802 from .field import Field return self.mount_as(Field)
20,845
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/unmountedtype.py
UnmountedType.InputField
(self)
return self.mount_as(InputField)
Mount the UnmountedType as InputField
Mount the UnmountedType as InputField
65
71
def InputField(self): # noqa: N802 """ Mount the UnmountedType as InputField """ from .inputfield import InputField return self.mount_as(InputField)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/unmountedtype.py#L65-L71
30
[ 0, 1, 2, 3 ]
57.142857
[ 4, 6 ]
28.571429
false
57.142857
7
1
71.428571
1
def InputField(self): # noqa: N802 from .inputfield import InputField return self.mount_as(InputField)
20,846
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/unmountedtype.py
UnmountedType.Argument
(self)
return self.mount_as(Argument)
Mount the UnmountedType as Argument
Mount the UnmountedType as Argument
73
79
def Argument(self): # noqa: N802 """ Mount the UnmountedType as Argument """ from .argument import Argument return self.mount_as(Argument)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/unmountedtype.py#L73-L79
30
[ 0, 1, 2, 3 ]
57.142857
[ 4, 6 ]
28.571429
false
57.142857
7
1
71.428571
1
def Argument(self): # noqa: N802 from .argument import Argument return self.mount_as(Argument)
20,847
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/unmountedtype.py
UnmountedType.__eq__
(self, other)
return self is other or ( isinstance(other, UnmountedType) and self.get_type() == other.get_type() and self.args == other.args and self.kwargs == other.kwargs )
81
87
def __eq__(self, other): return self is other or ( isinstance(other, UnmountedType) and self.get_type() == other.get_type() and self.args == other.args and self.kwargs == other.kwargs )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/unmountedtype.py#L81-L87
30
[ 0 ]
14.285714
[ 1 ]
14.285714
false
57.142857
7
5
85.714286
0
def __eq__(self, other): return self is other or ( isinstance(other, UnmountedType) and self.get_type() == other.get_type() and self.args == other.args and self.kwargs == other.kwargs )
20,848
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/mountedtype.py
MountedType.mounted
(cls, unmounted)
return cls( unmounted.get_type(), *unmounted.args, _creation_counter=unmounted.creation_counter, **unmounted.kwargs, )
Mount the UnmountedType instance
Mount the UnmountedType instance
7
20
def mounted(cls, unmounted): # noqa: N802 """ Mount the UnmountedType instance """ assert isinstance( unmounted, UnmountedType ), f"{cls.__name__} can't mount {repr(unmounted)}" return cls( unmounted.get_type(), *unmounted.args, _creation_counter=unmounted.creation_counter, **unmounted.kwargs, )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/mountedtype.py#L7-L20
30
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
100
[]
0
true
100
14
2
100
1
def mounted(cls, unmounted): # noqa: N802 assert isinstance( unmounted, UnmountedType ), f"{cls.__name__} can't mount {repr(unmounted)}" return cls( unmounted.get_type(), *unmounted.args, _creation_counter=unmounted.creation_counter, **unmounted.kwargs, )
20,849
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/base.py
BaseOptions.__init__
(self, class_type)
13
14
def __init__(self, class_type): self.class_type = class_type
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/base.py#L13-L14
30
[ 0, 1 ]
100
[]
0
true
90.625
2
1
100
0
def __init__(self, class_type): self.class_type = class_type
20,850
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/base.py
BaseOptions.freeze
(self)
16
17
def freeze(self): self._frozen = True
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/base.py#L16-L17
30
[ 0, 1 ]
100
[]
0
true
90.625
2
1
100
0
def freeze(self): self._frozen = True
20,851
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/base.py
BaseOptions.__setattr__
(self, name, value)
19
23
def __setattr__(self, name, value): if not self._frozen: super(BaseOptions, self).__setattr__(name, value) else: raise Exception(f"Can't modify frozen Options {self}")
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/base.py#L19-L23
30
[ 0, 1, 2 ]
60
[ 4 ]
20
false
90.625
5
2
80
0
def __setattr__(self, name, value): if not self._frozen: super(BaseOptions, self).__setattr__(name, value) else: raise Exception(f"Can't modify frozen Options {self}")
20,852
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/base.py
BaseOptions.__repr__
(self)
return f"<{self.__class__.__name__} name={repr(self.name)}>"
25
26
def __repr__(self): return f"<{self.__class__.__name__} name={repr(self.name)}>"
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/base.py#L25-L26
30
[ 0 ]
50
[ 1 ]
50
false
90.625
2
1
50
0
def __repr__(self): return f"<{self.__class__.__name__} name={repr(self.name)}>"
20,853
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/base.py
BaseType.create_type
(cls, class_name, **options)
return type(class_name, (cls,), {"Meta": options})
34
35
def create_type(cls, class_name, **options): return type(class_name, (cls,), {"Meta": options})
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/base.py#L34-L35
30
[ 0 ]
50
[ 1 ]
50
false
90.625
2
1
50
0
def create_type(cls, class_name, **options): return type(class_name, (cls,), {"Meta": options})
20,854
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/base.py
BaseType.__init_subclass_with_meta__
( cls, name=None, description=None, _meta=None, **_kwargs )
38
48
def __init_subclass_with_meta__( cls, name=None, description=None, _meta=None, **_kwargs ): assert "_meta" not in cls.__dict__, "Can't assign meta directly" if not _meta: return _meta.name = name or cls.__name__ _meta.description = description or trim_docstring(cls.__doc__) _meta.freeze() cls._meta = _meta super(BaseType, cls).__init_subclass_with_meta__()
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/base.py#L38-L48
30
[ 0, 3, 4, 5, 6, 7, 8, 9, 10 ]
81.818182
[]
0
false
90.625
11
5
100
0
def __init_subclass_with_meta__( cls, name=None, description=None, _meta=None, **_kwargs ): assert "_meta" not in cls.__dict__, "Can't assign meta directly" if not _meta: return _meta.name = name or cls.__name__ _meta.description = description or trim_docstring(cls.__doc__) _meta.freeze() cls._meta = _meta super(BaseType, cls).__init_subclass_with_meta__()
20,855
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/inputobjecttype.py
InputObjectTypeContainer.__init__
(self, *args, **kwargs)
21
24
def __init__(self, *args, **kwargs): dict.__init__(self, *args, **kwargs) for key in self._meta.fields: setattr(self, key, self.get(key, None))
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/inputobjecttype.py#L21-L24
30
[ 0, 1, 2, 3 ]
100
[]
0
true
94.594595
4
2
100
0
def __init__(self, *args, **kwargs): dict.__init__(self, *args, **kwargs) for key in self._meta.fields: setattr(self, key, self.get(key, None))
20,856
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/inputobjecttype.py
InputObjectType.__init_subclass_with_meta__
(cls, container=None, _meta=None, **options)
67
82
def __init_subclass_with_meta__(cls, container=None, _meta=None, **options): if not _meta: _meta = InputObjectTypeOptions(cls) fields = {} for base in reversed(cls.__mro__): fields.update(yank_fields_from_attrs(base.__dict__, _as=InputField)) if _meta.fields: _meta.fields.update(fields) else: _meta.fields = fields if container is None: container = type(cls.__name__, (InputObjectTypeContainer, cls), {}) _meta.container = container super(InputObjectType, cls).__init_subclass_with_meta__(_meta=_meta, **options)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/inputobjecttype.py#L67-L82
30
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15 ]
93.75
[]
0
false
94.594595
16
5
100
0
def __init_subclass_with_meta__(cls, container=None, _meta=None, **options): if not _meta: _meta = InputObjectTypeOptions(cls) fields = {} for base in reversed(cls.__mro__): fields.update(yank_fields_from_attrs(base.__dict__, _as=InputField)) if _meta.fields: _meta.fields.update(fields) else: _meta.fields = fields if container is None: container = type(cls.__name__, (InputObjectTypeContainer, cls), {}) _meta.container = container super(InputObjectType, cls).__init_subclass_with_meta__(_meta=_meta, **options)
20,857
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/inputobjecttype.py
InputObjectType.get_type
(cls)
return cls
This function is called when the unmounted type (InputObjectType instance) is mounted (as a Field, InputField or Argument)
This function is called when the unmounted type (InputObjectType instance) is mounted (as a Field, InputField or Argument)
85
90
def get_type(cls): """ This function is called when the unmounted type (InputObjectType instance) is mounted (as a Field, InputField or Argument) """ return cls
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/inputobjecttype.py#L85-L90
30
[ 0, 1, 2, 3, 4 ]
83.333333
[ 5 ]
16.666667
false
94.594595
6
1
83.333333
2
def get_type(cls): return cls
20,858
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/datetime.py
Date.serialize
(date)
return date.isoformat()
20
25
def serialize(date): if isinstance(date, datetime.datetime): date = date.date() if not isinstance(date, datetime.date): raise GraphQLError(f"Date cannot represent value: {repr(date)}") return date.isoformat()
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/datetime.py#L20-L25
30
[ 0 ]
16.666667
[ 1, 2, 3, 4, 5 ]
83.333333
false
54.929577
6
3
16.666667
0
def serialize(date): if isinstance(date, datetime.datetime): date = date.date() if not isinstance(date, datetime.date): raise GraphQLError(f"Date cannot represent value: {repr(date)}") return date.isoformat()
20,859
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/datetime.py
Date.parse_literal
(cls, node, _variables=None)
return cls.parse_value(node.value)
28
33
def parse_literal(cls, node, _variables=None): if not isinstance(node, StringValueNode): raise GraphQLError( f"Date cannot represent non-string value: {print_ast(node)}" ) return cls.parse_value(node.value)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/datetime.py#L28-L33
30
[ 0, 1, 5 ]
50
[ 2 ]
16.666667
false
54.929577
6
2
83.333333
0
def parse_literal(cls, node, _variables=None): if not isinstance(node, StringValueNode): raise GraphQLError( f"Date cannot represent non-string value: {print_ast(node)}" ) return cls.parse_value(node.value)
20,860
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/datetime.py
Date.parse_value
(value)
36
44
def parse_value(value): if isinstance(value, datetime.date): return value if not isinstance(value, str): raise GraphQLError(f"Date cannot represent non-string value: {repr(value)}") try: return parse_date(value) except ValueError: raise GraphQLError(f"Date cannot represent value: {repr(value)}")
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/datetime.py#L36-L44
30
[ 0, 1, 3, 5, 6 ]
55.555556
[ 2, 4, 7, 8 ]
44.444444
false
54.929577
9
4
55.555556
0
def parse_value(value): if isinstance(value, datetime.date): return value if not isinstance(value, str): raise GraphQLError(f"Date cannot represent non-string value: {repr(value)}") try: return parse_date(value) except ValueError: raise GraphQLError(f"Date cannot represent value: {repr(value)}")
20,861
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/datetime.py
DateTime.serialize
(dt)
return dt.isoformat()
55
58
def serialize(dt): if not isinstance(dt, (datetime.datetime, datetime.date)): raise GraphQLError(f"DateTime cannot represent value: {repr(dt)}") return dt.isoformat()
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/datetime.py#L55-L58
30
[ 0 ]
25
[ 1, 2, 3 ]
75
false
54.929577
4
2
25
0
def serialize(dt): if not isinstance(dt, (datetime.datetime, datetime.date)): raise GraphQLError(f"DateTime cannot represent value: {repr(dt)}") return dt.isoformat()
20,862
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/datetime.py
DateTime.parse_literal
(cls, node, _variables=None)
return cls.parse_value(node.value)
61
66
def parse_literal(cls, node, _variables=None): if not isinstance(node, StringValueNode): raise GraphQLError( f"DateTime cannot represent non-string value: {print_ast(node)}" ) return cls.parse_value(node.value)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/datetime.py#L61-L66
30
[ 0, 1, 5 ]
50
[ 2 ]
16.666667
false
54.929577
6
2
83.333333
0
def parse_literal(cls, node, _variables=None): if not isinstance(node, StringValueNode): raise GraphQLError( f"DateTime cannot represent non-string value: {print_ast(node)}" ) return cls.parse_value(node.value)
20,863
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/datetime.py
DateTime.parse_value
(value)
69
79
def parse_value(value): if isinstance(value, datetime.datetime): return value if not isinstance(value, str): raise GraphQLError( f"DateTime cannot represent non-string value: {repr(value)}" ) try: return parse_datetime(value) except ValueError: raise GraphQLError(f"DateTime cannot represent value: {repr(value)}")
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/datetime.py#L69-L79
30
[ 0, 1, 3, 7, 8 ]
45.454545
[ 2, 4, 9, 10 ]
36.363636
false
54.929577
11
4
63.636364
0
def parse_value(value): if isinstance(value, datetime.datetime): return value if not isinstance(value, str): raise GraphQLError( f"DateTime cannot represent non-string value: {repr(value)}" ) try: return parse_datetime(value) except ValueError: raise GraphQLError(f"DateTime cannot represent value: {repr(value)}")
20,864
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/datetime.py
Time.serialize
(time)
return time.isoformat()
90
93
def serialize(time): if not isinstance(time, datetime.time): raise GraphQLError(f"Time cannot represent value: {repr(time)}") return time.isoformat()
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/datetime.py#L90-L93
30
[ 0 ]
25
[ 1, 2, 3 ]
75
false
54.929577
4
2
25
0
def serialize(time): if not isinstance(time, datetime.time): raise GraphQLError(f"Time cannot represent value: {repr(time)}") return time.isoformat()
20,865
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/datetime.py
Time.parse_literal
(cls, node, _variables=None)
return cls.parse_value(node.value)
96
101
def parse_literal(cls, node, _variables=None): if not isinstance(node, StringValueNode): raise GraphQLError( f"Time cannot represent non-string value: {print_ast(node)}" ) return cls.parse_value(node.value)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/datetime.py#L96-L101
30
[ 0 ]
16.666667
[ 1, 2, 5 ]
50
false
54.929577
6
2
50
0
def parse_literal(cls, node, _variables=None): if not isinstance(node, StringValueNode): raise GraphQLError( f"Time cannot represent non-string value: {print_ast(node)}" ) return cls.parse_value(node.value)
20,866
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/datetime.py
Time.parse_value
(cls, value)
104
112
def parse_value(cls, value): if isinstance(value, datetime.time): return value if not isinstance(value, str): raise GraphQLError(f"Time cannot represent non-string value: {repr(value)}") try: return parse_time(value) except ValueError: raise GraphQLError(f"Time cannot represent value: {repr(value)}")
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/datetime.py#L104-L112
30
[ 0 ]
11.111111
[ 1, 2, 3, 4, 5, 6, 7, 8 ]
88.888889
false
54.929577
9
4
11.111111
0
def parse_value(cls, value): if isinstance(value, datetime.time): return value if not isinstance(value, str): raise GraphQLError(f"Time cannot represent non-string value: {repr(value)}") try: return parse_time(value) except ValueError: raise GraphQLError(f"Time cannot represent value: {repr(value)}")
20,867
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/argument.py
to_arguments
(args, extra_args=None)
return arguments
83
120
def to_arguments(args, extra_args=None): from .unmountedtype import UnmountedType from .field import Field from .inputfield import InputField if extra_args: extra_args = sorted(extra_args.items(), key=lambda f: f[1]) else: extra_args = [] iter_arguments = chain(args.items(), extra_args) arguments = {} for default_name, arg in iter_arguments: if isinstance(arg, Dynamic): arg = arg.get_type() if arg is None: # If the Dynamic type returned None # then we skip the Argument continue if isinstance(arg, UnmountedType): arg = Argument.mounted(arg) if isinstance(arg, (InputField, Field)): raise ValueError( f"Expected {default_name} to be Argument, " f"but received {type(arg).__name__}. Try using Argument({arg.type})." ) if not isinstance(arg, Argument): raise ValueError(f'Unknown argument "{default_name}".') arg_name = default_name or arg.name assert ( arg_name not in arguments ), f'More than one Argument have same name "{arg_name}".' arguments[arg_name] = arg return arguments
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/argument.py#L83-L120
30
[ 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 18, 19, 20, 21, 22, 27, 28, 30, 31, 32, 35, 36, 37 ]
65.789474
[ 13, 14, 17, 23, 29 ]
13.157895
false
86.956522
38
10
86.842105
0
def to_arguments(args, extra_args=None): from .unmountedtype import UnmountedType from .field import Field from .inputfield import InputField if extra_args: extra_args = sorted(extra_args.items(), key=lambda f: f[1]) else: extra_args = [] iter_arguments = chain(args.items(), extra_args) arguments = {} for default_name, arg in iter_arguments: if isinstance(arg, Dynamic): arg = arg.get_type() if arg is None: # If the Dynamic type returned None # then we skip the Argument continue if isinstance(arg, UnmountedType): arg = Argument.mounted(arg) if isinstance(arg, (InputField, Field)): raise ValueError( f"Expected {default_name} to be Argument, " f"but received {type(arg).__name__}. Try using Argument({arg.type})." ) if not isinstance(arg, Argument): raise ValueError(f'Unknown argument "{default_name}".') arg_name = default_name or arg.name assert ( arg_name not in arguments ), f'More than one Argument have same name "{arg_name}".' arguments[arg_name] = arg return arguments
20,868
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/argument.py
Argument.__init__
( self, type_, default_value=Undefined, deprecation_reason=None, description=None, name=None, required=False, _creation_counter=None, )
45
67
def __init__( self, type_, default_value=Undefined, deprecation_reason=None, description=None, name=None, required=False, _creation_counter=None, ): super(Argument, self).__init__(_creation_counter=_creation_counter) if required: assert ( deprecation_reason is None ), f"Argument {name} is required, cannot deprecate it." type_ = NonNull(type_) self.name = name self._type = type_ self.default_value = default_value self.description = description self.deprecation_reason = deprecation_reason
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/argument.py#L45-L67
30
[ 0, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21, 22 ]
52.173913
[]
0
false
86.956522
23
3
100
0
def __init__( self, type_, default_value=Undefined, deprecation_reason=None, description=None, name=None, required=False, _creation_counter=None, ): super(Argument, self).__init__(_creation_counter=_creation_counter) if required: assert ( deprecation_reason is None ), f"Argument {name} is required, cannot deprecate it." type_ = NonNull(type_) self.name = name self._type = type_ self.default_value = default_value self.description = description self.deprecation_reason = deprecation_reason
20,869
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/argument.py
Argument.type
(self)
return get_type(self._type)
70
71
def type(self): return get_type(self._type)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/argument.py#L70-L71
30
[ 0, 1 ]
100
[]
0
true
86.956522
2
1
100
0
def type(self): return get_type(self._type)
20,870
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/argument.py
Argument.__eq__
(self, other)
return isinstance(other, Argument) and ( self.name == other.name and self.type == other.type and self.default_value == other.default_value and self.description == other.description and self.deprecation_reason == other.deprecation_reason )
73
80
def __eq__(self, other): return isinstance(other, Argument) and ( self.name == other.name and self.type == other.type and self.default_value == other.default_value and self.description == other.description and self.deprecation_reason == other.deprecation_reason )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/argument.py#L73-L80
30
[ 0 ]
12.5
[ 1 ]
12.5
false
86.956522
8
6
87.5
0
def __eq__(self, other): return isinstance(other, Argument) and ( self.name == other.name and self.type == other.type and self.default_value == other.default_value and self.description == other.description and self.deprecation_reason == other.deprecation_reason )
20,871
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/dynamic.py
Dynamic.__init__
(self, type_, with_schema=False, _creation_counter=None)
13
17
def __init__(self, type_, with_schema=False, _creation_counter=None): super(Dynamic, self).__init__(_creation_counter=_creation_counter) assert inspect.isfunction(type_) or isinstance(type_, partial) self.type = type_ self.with_schema = with_schema
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/dynamic.py#L13-L17
30
[ 0 ]
20
[ 1, 2, 3, 4 ]
80
false
46.153846
5
3
20
0
def __init__(self, type_, with_schema=False, _creation_counter=None): super(Dynamic, self).__init__(_creation_counter=_creation_counter) assert inspect.isfunction(type_) or isinstance(type_, partial) self.type = type_ self.with_schema = with_schema
20,872
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/dynamic.py
Dynamic.get_type
(self, schema=None)
return self.type()
19
22
def get_type(self, schema=None): if schema and self.with_schema: return self.type(schema=schema) return self.type()
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/dynamic.py#L19-L22
30
[ 0 ]
25
[ 1, 2, 3 ]
75
false
46.153846
4
3
25
0
def get_type(self, schema=None): if schema and self.with_schema: return self.type(schema=schema) return self.type()
20,873
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/interface.py
Interface.__init_subclass_with_meta__
(cls, _meta=None, interfaces=(), **options)
49
65
def __init_subclass_with_meta__(cls, _meta=None, interfaces=(), **options): if not _meta: _meta = InterfaceOptions(cls) fields = {} for base in reversed(cls.__mro__): fields.update(yank_fields_from_attrs(base.__dict__, _as=Field)) if _meta.fields: _meta.fields.update(fields) else: _meta.fields = fields if not _meta.interfaces: _meta.interfaces = interfaces super(Interface, cls).__init_subclass_with_meta__(_meta=_meta, **options)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/interface.py#L49-L65
30
[ 0, 1, 3, 4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16 ]
82.352941
[ 2, 11 ]
11.764706
false
76.666667
17
5
88.235294
0
def __init_subclass_with_meta__(cls, _meta=None, interfaces=(), **options): if not _meta: _meta = InterfaceOptions(cls) fields = {} for base in reversed(cls.__mro__): fields.update(yank_fields_from_attrs(base.__dict__, _as=Field)) if _meta.fields: _meta.fields.update(fields) else: _meta.fields = fields if not _meta.interfaces: _meta.interfaces = interfaces super(Interface, cls).__init_subclass_with_meta__(_meta=_meta, **options)
20,874
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/interface.py
Interface.resolve_type
(cls, instance, info)
68
72
def resolve_type(cls, instance, info): from .objecttype import ObjectType if isinstance(instance, ObjectType): return type(instance)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/interface.py#L68-L72
30
[ 0 ]
20
[ 1, 3, 4 ]
60
false
76.666667
5
2
40
0
def resolve_type(cls, instance, info): from .objecttype import ObjectType if isinstance(instance, ObjectType): return type(instance)
20,875
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/base64.py
Base64.serialize
(value)
return b64encode(value).decode("utf-8")
16
22
def serialize(value): if not isinstance(value, bytes): if isinstance(value, str): value = value.encode("utf-8") else: value = str(value).encode("utf-8") return b64encode(value).decode("utf-8")
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/base64.py#L16-L22
30
[ 0 ]
14.285714
[ 1, 2, 3, 5, 6 ]
71.428571
false
67.857143
7
3
28.571429
0
def serialize(value): if not isinstance(value, bytes): if isinstance(value, str): value = value.encode("utf-8") else: value = str(value).encode("utf-8") return b64encode(value).decode("utf-8")
20,876
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/base64.py
Base64.parse_literal
(cls, node, _variables=None)
return cls.parse_value(node.value)
25
30
def parse_literal(cls, node, _variables=None): if not isinstance(node, StringValueNode): raise GraphQLError( f"Base64 cannot represent non-string value: {print_ast(node)}" ) return cls.parse_value(node.value)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/base64.py#L25-L30
30
[ 0, 1, 5 ]
50
[ 2 ]
16.666667
false
67.857143
6
2
83.333333
0
def parse_literal(cls, node, _variables=None): if not isinstance(node, StringValueNode): raise GraphQLError( f"Base64 cannot represent non-string value: {print_ast(node)}" ) return cls.parse_value(node.value)
20,877
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/base64.py
Base64.parse_value
(value)
33
43
def parse_value(value): if not isinstance(value, bytes): if not isinstance(value, str): raise GraphQLError( f"Base64 cannot represent non-string value: {repr(value)}" ) value = value.encode("utf-8") try: return b64decode(value, validate=True).decode("utf-8") except _Error: raise GraphQLError(f"Base64 cannot decode value: {repr(value)}")
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/base64.py#L33-L43
30
[ 0, 1, 2, 6, 7, 8 ]
54.545455
[ 3, 9, 10 ]
27.272727
false
67.857143
11
4
72.727273
0
def parse_value(value): if not isinstance(value, bytes): if not isinstance(value, str): raise GraphQLError( f"Base64 cannot represent non-string value: {repr(value)}" ) value = value.encode("utf-8") try: return b64decode(value, validate=True).decode("utf-8") except _Error: raise GraphQLError(f"Base64 cannot decode value: {repr(value)}")
20,878
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
cmp
(a, b)
return (a > b) - (a < b)
150
151
def cmp(a, b): return (a > b) - (a < b)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L150-L151
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def cmp(a, b): return (a > b) - (a < b)
20,879
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
lonlat
(x, y, z=0)
return Point(y, x, z)
``geopy.distance.distance`` accepts coordinates in ``(y, x)``/``(lat, lon)`` order, while some other libraries and systems might use ``(x, y)``/``(lon, lat)``. This function provides a convenient way to convert coordinates of the ``(x, y)``/``(lon, lat)`` format to a :class:`geopy.point.Point` instance. Example:: >>> from geopy.distance import lonlat, distance >>> newport_ri_xy = (-71.312796, 41.49008) >>> cleveland_oh_xy = (-81.695391, 41.499498) >>> print(distance(lonlat(*newport_ri_xy), lonlat(*cleveland_oh_xy)).miles) 538.3904453677203 :param x: longitude :param y: latitude :param z: (optional) altitude :return: Point(latitude, longitude, altitude)
``geopy.distance.distance`` accepts coordinates in ``(y, x)``/``(lat, lon)`` order, while some other libraries and systems might use ``(x, y)``/``(lon, lat)``.
154
176
def lonlat(x, y, z=0): """ ``geopy.distance.distance`` accepts coordinates in ``(y, x)``/``(lat, lon)`` order, while some other libraries and systems might use ``(x, y)``/``(lon, lat)``. This function provides a convenient way to convert coordinates of the ``(x, y)``/``(lon, lat)`` format to a :class:`geopy.point.Point` instance. Example:: >>> from geopy.distance import lonlat, distance >>> newport_ri_xy = (-71.312796, 41.49008) >>> cleveland_oh_xy = (-81.695391, 41.499498) >>> print(distance(lonlat(*newport_ri_xy), lonlat(*cleveland_oh_xy)).miles) 538.3904453677203 :param x: longitude :param y: latitude :param z: (optional) altitude :return: Point(latitude, longitude, altitude) """ return Point(y, x, z)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L154-L176
31
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 ]
100
[]
0
true
95.977011
23
1
100
19
def lonlat(x, y, z=0): return Point(y, x, z)
20,880
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
_ensure_same_altitude
(a, b)
179
184
def _ensure_same_altitude(a, b): if abs(a.altitude - b.altitude) > 1e-6: raise ValueError( 'Calculating distance between points with different altitudes ' 'is not supported' )
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L179-L184
31
[ 0, 1, 2 ]
50
[]
0
false
95.977011
6
2
100
0
def _ensure_same_altitude(a, b): if abs(a.altitude - b.altitude) > 1e-6: raise ValueError( 'Calculating distance between points with different altitudes ' 'is not supported' )
20,881
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__init__
(self, *args, **kwargs)
There are 3 ways to create a distance: - From kilometers:: >>> from geopy.distance import Distance >>> Distance(1.42) Distance(1.42) - From units:: >>> from geopy.distance import Distance >>> Distance(kilometers=1.42) Distance(1.42) >>> Distance(miles=1) Distance(1.609344) - From points (for non-abstract distances only), calculated as a sum of distances between all points:: >>> from geopy.distance import geodesic >>> geodesic((40, 160), (40.1, 160.1)) Distance(14.003702498106215) >>> geodesic((40, 160), (40.1, 160.1), (40.2, 160.2)) Distance(27.999954644813478)
There are 3 ways to create a distance:
240
279
def __init__(self, *args, **kwargs): """ There are 3 ways to create a distance: - From kilometers:: >>> from geopy.distance import Distance >>> Distance(1.42) Distance(1.42) - From units:: >>> from geopy.distance import Distance >>> Distance(kilometers=1.42) Distance(1.42) >>> Distance(miles=1) Distance(1.609344) - From points (for non-abstract distances only), calculated as a sum of distances between all points:: >>> from geopy.distance import geodesic >>> geodesic((40, 160), (40.1, 160.1)) Distance(14.003702498106215) >>> geodesic((40, 160), (40.1, 160.1), (40.2, 160.2)) Distance(27.999954644813478) """ kilometers = kwargs.pop('kilometers', 0) if len(args) == 1: # if we only get one argument we assume # it's a known distance instead of # calculating it first kilometers += args[0] elif len(args) > 1: for a, b in util.pairwise(args): kilometers += self.measure(a, b) kilometers += units.kilometers(**kwargs) self.__kilometers = kilometers
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L240-L279
31
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 ]
100
[]
0
true
95.977011
40
4
100
24
def __init__(self, *args, **kwargs): kilometers = kwargs.pop('kilometers', 0) if len(args) == 1: # if we only get one argument we assume # it's a known distance instead of # calculating it first kilometers += args[0] elif len(args) > 1: for a, b in util.pairwise(args): kilometers += self.measure(a, b) kilometers += units.kilometers(**kwargs) self.__kilometers = kilometers
20,882
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__add__
(self, other)
281
287
def __add__(self, other): if isinstance(other, Distance): return self.__class__(self.kilometers + other.kilometers) else: raise TypeError( "Distance instance must be added with Distance instance." )
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L281-L287
31
[ 0, 1, 2, 4 ]
57.142857
[]
0
false
95.977011
7
2
100
0
def __add__(self, other): if isinstance(other, Distance): return self.__class__(self.kilometers + other.kilometers) else: raise TypeError( "Distance instance must be added with Distance instance." )
20,883
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__neg__
(self)
return self.__class__(-self.kilometers)
289
290
def __neg__(self): return self.__class__(-self.kilometers)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L289-L290
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def __neg__(self): return self.__class__(-self.kilometers)
20,884
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__sub__
(self, other)
return self + -other
292
293
def __sub__(self, other): return self + -other
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L292-L293
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def __sub__(self, other): return self + -other
20,885
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__mul__
(self, other)
295
301
def __mul__(self, other): if isinstance(other, Distance): raise TypeError( "Distance instance must be multiplicated with numbers." ) else: return self.__class__(self.kilometers * other)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L295-L301
31
[ 0, 1, 2, 6 ]
57.142857
[]
0
false
95.977011
7
2
100
0
def __mul__(self, other): if isinstance(other, Distance): raise TypeError( "Distance instance must be multiplicated with numbers." ) else: return self.__class__(self.kilometers * other)
20,886
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__rmul__
(self, other)
303
309
def __rmul__(self, other): if isinstance(other, Distance): raise TypeError( "Distance instance must be multiplicated with numbers." ) else: return self.__class__(other * self.kilometers)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L303-L309
31
[ 0, 1, 6 ]
42.857143
[ 2 ]
14.285714
false
95.977011
7
2
85.714286
0
def __rmul__(self, other): if isinstance(other, Distance): raise TypeError( "Distance instance must be multiplicated with numbers." ) else: return self.__class__(other * self.kilometers)
20,887
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__truediv__
(self, other)
311
315
def __truediv__(self, other): if isinstance(other, Distance): return self.kilometers / other.kilometers else: return self.__class__(self.kilometers / other)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L311-L315
31
[ 0, 1, 2, 4 ]
80
[]
0
false
95.977011
5
2
100
0
def __truediv__(self, other): if isinstance(other, Distance): return self.kilometers / other.kilometers else: return self.__class__(self.kilometers / other)
20,888
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__floordiv__
(self, other)
317
321
def __floordiv__(self, other): if isinstance(other, Distance): return self.kilometers // other.kilometers else: return self.__class__(self.kilometers // other)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L317-L321
31
[ 0, 1, 2, 4 ]
80
[]
0
false
95.977011
5
2
100
0
def __floordiv__(self, other): if isinstance(other, Distance): return self.kilometers // other.kilometers else: return self.__class__(self.kilometers // other)
20,889
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__abs__
(self)
return self.__class__(abs(self.kilometers))
323
324
def __abs__(self): return self.__class__(abs(self.kilometers))
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L323-L324
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def __abs__(self): return self.__class__(abs(self.kilometers))
20,890
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__bool__
(self)
return bool(self.kilometers)
326
327
def __bool__(self): return bool(self.kilometers)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L326-L327
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def __bool__(self): return bool(self.kilometers)
20,891
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.measure
(self, a, b)
329
332
def measure(self, a, b): # Intentionally not documented, because this method is not supposed # to be used directly. raise NotImplementedError("Distance is an abstract class")
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L329-L332
31
[ 0, 1, 2 ]
75
[ 3 ]
25
false
95.977011
4
1
75
0
def measure(self, a, b): # Intentionally not documented, because this method is not supposed # to be used directly. raise NotImplementedError("Distance is an abstract class")
20,892
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.destination
(self, point, bearing, distance=None)
Calculate destination point using a starting point, bearing and a distance. This method works for non-abstract distances only. Example: a point 10 miles east from ``(34, 148)``:: >>> import geopy.distance >>> geopy.distance.distance(miles=10).destination((34, 148), bearing=90) Point(33.99987666492774, 148.17419994321995, 0.0) :param point: Starting point. :type point: :class:`geopy.point.Point`, list or tuple of ``(latitude, longitude)``, or string as ``"%(latitude)s, %(longitude)s"``. :param float bearing: Bearing in degrees: 0 -- North, 90 -- East, 180 -- South, 270 or -90 -- West. :param distance: Distance, can be used to override this instance:: >>> from geopy.distance import distance, Distance >>> distance(miles=10).destination((34, 148), bearing=90, \ distance=Distance(100)) Point(33.995238229104764, 149.08238904409637, 0.0) :type distance: :class:`.Distance` :rtype: :class:`geopy.point.Point`
Calculate destination point using a starting point, bearing and a distance. This method works for non-abstract distances only.
334
364
def destination(self, point, bearing, distance=None): """ Calculate destination point using a starting point, bearing and a distance. This method works for non-abstract distances only. Example: a point 10 miles east from ``(34, 148)``:: >>> import geopy.distance >>> geopy.distance.distance(miles=10).destination((34, 148), bearing=90) Point(33.99987666492774, 148.17419994321995, 0.0) :param point: Starting point. :type point: :class:`geopy.point.Point`, list or tuple of ``(latitude, longitude)``, or string as ``"%(latitude)s, %(longitude)s"``. :param float bearing: Bearing in degrees: 0 -- North, 90 -- East, 180 -- South, 270 or -90 -- West. :param distance: Distance, can be used to override this instance:: >>> from geopy.distance import distance, Distance >>> distance(miles=10).destination((34, 148), bearing=90, \ distance=Distance(100)) Point(33.995238229104764, 149.08238904409637, 0.0) :type distance: :class:`.Distance` :rtype: :class:`geopy.point.Point` """ raise NotImplementedError("Distance is an abstract class")
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L334-L364
31
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 ]
96.774194
[ 30 ]
3.225806
false
95.977011
31
1
96.774194
27
def destination(self, point, bearing, distance=None): raise NotImplementedError("Distance is an abstract class")
20,893
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__repr__
(self)
return 'Distance(%s)' % self.kilometers
366
367
def __repr__(self): # pragma: no cover return 'Distance(%s)' % self.kilometers
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L366-L367
31
[]
0
[]
0
false
95.977011
2
1
100
0
def __repr__(self): # pragma: no cover return 'Distance(%s)' % self.kilometers
20,894
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__str__
(self)
return '%s km' % self.__kilometers
369
370
def __str__(self): # pragma: no cover return '%s km' % self.__kilometers
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L369-L370
31
[]
0
[]
0
false
95.977011
2
1
100
0
def __str__(self): # pragma: no cover return '%s km' % self.__kilometers
20,895
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__cmp__
(self, other)
372
376
def __cmp__(self, other): # py2 only if isinstance(other, Distance): return cmp(self.kilometers, other.kilometers) else: return cmp(self.kilometers, other)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L372-L376
31
[ 0, 1, 2, 4 ]
80
[]
0
false
95.977011
5
2
100
0
def __cmp__(self, other): # py2 only if isinstance(other, Distance): return cmp(self.kilometers, other.kilometers) else: return cmp(self.kilometers, other)
20,896
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__hash__
(self)
return hash(self.kilometers)
378
379
def __hash__(self): return hash(self.kilometers)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L378-L379
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def __hash__(self): return hash(self.kilometers)
20,897
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__eq__
(self, other)
return self.__cmp__(other) == 0
381
382
def __eq__(self, other): return self.__cmp__(other) == 0
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L381-L382
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def __eq__(self, other): return self.__cmp__(other) == 0
20,898
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__ne__
(self, other)
return self.__cmp__(other) != 0
384
385
def __ne__(self, other): return self.__cmp__(other) != 0
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L384-L385
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def __ne__(self, other): return self.__cmp__(other) != 0
20,899
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__gt__
(self, other)
return self.__cmp__(other) > 0
387
388
def __gt__(self, other): return self.__cmp__(other) > 0
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L387-L388
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def __gt__(self, other): return self.__cmp__(other) > 0
20,900
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__lt__
(self, other)
return self.__cmp__(other) < 0
390
391
def __lt__(self, other): return self.__cmp__(other) < 0
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L390-L391
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def __lt__(self, other): return self.__cmp__(other) < 0
20,901
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__ge__
(self, other)
return self.__cmp__(other) >= 0
393
394
def __ge__(self, other): return self.__cmp__(other) >= 0
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L393-L394
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def __ge__(self, other): return self.__cmp__(other) >= 0
20,902
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.__le__
(self, other)
return self.__cmp__(other) <= 0
396
397
def __le__(self, other): return self.__cmp__(other) <= 0
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L396-L397
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def __le__(self, other): return self.__cmp__(other) <= 0
20,903
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.feet
(self)
return units.feet(kilometers=self.kilometers)
400
401
def feet(self): return units.feet(kilometers=self.kilometers)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L400-L401
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def feet(self): return units.feet(kilometers=self.kilometers)
20,904
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.ft
(self)
return self.feet
404
405
def ft(self): return self.feet
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L404-L405
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def ft(self): return self.feet
20,905
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.kilometers
(self)
return self.__kilometers
408
409
def kilometers(self): return self.__kilometers
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L408-L409
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def kilometers(self): return self.__kilometers
20,906
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.km
(self)
return self.kilometers
412
413
def km(self): return self.kilometers
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L412-L413
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def km(self): return self.kilometers
20,907
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.m
(self)
return self.meters
416
417
def m(self): return self.meters
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L416-L417
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def m(self): return self.meters
20,908
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.meters
(self)
return units.meters(kilometers=self.kilometers)
420
421
def meters(self): return units.meters(kilometers=self.kilometers)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L420-L421
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def meters(self): return units.meters(kilometers=self.kilometers)
20,909
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.mi
(self)
return self.miles
424
425
def mi(self): return self.miles
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L424-L425
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def mi(self): return self.miles
20,910
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.miles
(self)
return units.miles(kilometers=self.kilometers)
428
429
def miles(self): return units.miles(kilometers=self.kilometers)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L428-L429
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def miles(self): return units.miles(kilometers=self.kilometers)
20,911
geopy/geopy
ef48a8cbb85f842c0820333e53e7ebde7db382a3
geopy/distance.py
Distance.nautical
(self)
return units.nautical(kilometers=self.kilometers)
432
433
def nautical(self): return units.nautical(kilometers=self.kilometers)
https://github.com/geopy/geopy/blob/ef48a8cbb85f842c0820333e53e7ebde7db382a3/project31/geopy/distance.py#L432-L433
31
[ 0, 1 ]
100
[]
0
true
95.977011
2
1
100
0
def nautical(self): return units.nautical(kilometers=self.kilometers)
20,912