repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
falcon | falcon/media/__init__.py | .py | from .base import BaseHandler
from .base import BinaryBaseHandlerWS
from .base import TextBaseHandlerWS
from .handlers import Handlers
from .handlers import MissingDependencyHandler
from .json import JSONHandler
from .json import JSONHandlerWS
from .msgpack import MessagePackHandler
from .msgpack import MessagePackHand... | 26 | 701 |
falcon | falcon/media/handlers.py | .py | from __future__ import annotations
from collections import UserDict
from collections.abc import Mapping
from collections.abc import Sequence
import functools
from typing import (
Any,
cast,
Literal,
NoReturn,
Optional,
overload,
Protocol,
)
from falcon import errors
from falcon._typing imp... | 212 | 7,668 |
falcon | falcon/media/multipart.py | .py | # Copyright 2019-2026 by Vytautas Liuolia.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 639 | 23,814 |
falcon | falcon/media/msgpack.py | .py | from __future__ import annotations
from typing import Any, Callable, Protocol
from falcon import errors
from falcon.media.base import BaseHandler
from falcon.media.base import BinaryBaseHandlerWS
from falcon.typing import AsyncReadableIO
from falcon.typing import ReadableIO
class MessagePackHandler(BaseHandler):
... | 122 | 3,952 |
falcon | falcon/media/urlencoded.py | .py | from __future__ import annotations
from typing import Any
from urllib.parse import urlencode
from falcon import errors
from falcon.media.base import BaseHandler
from falcon.typing import AsyncReadableIO
from falcon.typing import ReadableIO
from falcon.util.uri import parse_query_string
class URLEncodedFormHandler(B... | 82 | 3,097 |
falcon | falcon/media/base.py | .py | from __future__ import annotations
import abc
import io
from falcon._typing import DeserializeSync
from falcon._typing import SerializeSync
from falcon.constants import MEDIA_JSON
from falcon.typing import AsyncReadableIO
from falcon.typing import ReadableIO
class BaseHandler(metaclass=abc.ABCMeta):
"""Abstract... | 247 | 9,262 |
falcon | falcon/media/validators/__init__.py | .py | from . import jsonschema
__all__ = ('jsonschema',)
| 4 | 52 |
falcon | falcon/media/validators/jsonschema.py | .py | from __future__ import annotations
from functools import wraps
from inspect import iscoroutinefunction
from typing import Any, Callable, Optional, TYPE_CHECKING
import falcon
try:
import jsonschema
except ImportError: # pragma: nocover
pass
if TYPE_CHECKING:
import falcon as wsgi
from falcon import... | 170 | 5,581 |
falcon | falcon/asgi/_asgi_helpers.py | .py | # Copyright 2020-2026 by Vytautas Liuolia.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 102 | 3,740 |
falcon | falcon/asgi/app.py | .py | # Copyright 2019-2021 by Kurt Griffiths
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in... | 1,455 | 61,708 |
falcon | falcon/asgi/request.py | .py | # Copyright 2019-2020 by Kurt Griffiths
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in... | 934 | 36,765 |
falcon | falcon/asgi/__init__.py | .py | # Copyright 2019 by Kurt Griffiths.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | 46 | 1,350 |
falcon | falcon/asgi/_request_helpers.py | .py | # Copyright 2019 by Kurt Griffiths
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 46 | 1,487 |
falcon | falcon/asgi/multipart.py | .py | # Copyright 2019-2026 by Vytautas Liuolia.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 284 | 10,816 |
falcon | falcon/asgi/structures.py | .py | from __future__ import annotations
from falcon.constants import MEDIA_JSON
from falcon.media import BaseHandler
from falcon.media.json import _DEFAULT_JSON_HANDLER
__all__ = ('SSEvent',)
class SSEvent:
"""Represents a Server-Sent Event (SSE).
Instances of this class can be yielded by an async generator in ... | 174 | 6,646 |
falcon | falcon/asgi/ws.py | .py | from __future__ import annotations
import asyncio
import collections
from collections.abc import Iterable
from collections.abc import Mapping
from enum import auto
from enum import Enum
import re
from typing import Any
from falcon import errors
from falcon import media
from falcon import status_codes
from falcon._typ... | 833 | 31,176 |
falcon | falcon/asgi/response.py | .py | # Copyright 2019 by Kurt Griffiths
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 397 | 15,925 |
falcon | falcon/asgi/reader.py | .py | # Copyright 2019-2026 by Vytautas Liuolia.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 374 | 12,683 |
falcon | falcon/asgi/stream.py | .py | # Copyright 2019 by Kurt Griffiths
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 478 | 17,942 |
falcon | falcon/bench/__init__.py | .py | """Falcon benchmarks."""
from falcon.bench.bench import main # NOQA
| 4 | 70 |
falcon | falcon/bench/create.py | .py | # Copyright 2014 by Rackspace Hosting, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed t... | 131 | 3,299 |
falcon | falcon/bench/bench.py | .py | #!/usr/bin/env python
# Copyright 2014 by Rackspace Hosting, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by app... | 435 | 11,335 |
falcon | falcon/bench/queues/api.py | .py | # Copyright (c) 2013 Rackspace, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wr... | 74 | 2,600 |
falcon | falcon/bench/dj/manage.py | .py | #!/usr/bin/env python
import os
import sys
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dj.settings')
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
... | 23 | 808 |
falcon | falcon/bench/dj/dj/wsgi.py | .py | """WSGI config for dj project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_M... | 16 | 381 |
falcon | falcon/bench/dj/dj/urls.py | .py | from django.urls import re_path as url
from hello import views
urlpatterns = [url(r'^hello/(?P<account_id>[0-9]+)/test$', views.hello)]
| 5 | 137 |
falcon | falcon/bench/dj/dj/settings.py | .py | """Django settings for dj project.
Generated by 'django-admin startproject' using Django 1.11.3.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
from... | 125 | 3,142 |
falcon | falcon/bench/dj/hello/apps.py | .py | from django.apps import AppConfig
class HelloConfig(AppConfig):
name = 'hello'
| 6 | 85 |
falcon | falcon/bench/dj/hello/views.py | .py | import django
from django.http import HttpResponse
_body = django.x_test_body
_headers = django.x_test_headers
def hello(request, account_id):
user_agent = request.META['HTTP_USER_AGENT'] # NOQA
limit = request.GET.get('limit', '10') # NOQA
response = HttpResponse(_body)
for name, value in _header... | 17 | 383 |
falcon | falcon/bench/nuts/setup.py | .py | try:
from setuptools import setup, find_packages
except ImportError:
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup, find_packages
setup(
name='nuts',
version='0.1',
description='',
author='',
author_email='',
install_requires=['pecan'],
t... | 21 | 441 |
falcon | falcon/bench/nuts/config.py | .py | # Server Specific Configurations
server = {'port': '8080', 'host': '0.0.0.0'}
# Pecan Application Configurations
app = {
'root': 'nuts.controllers.root.RootController',
'modules': ['nuts'],
'static_root': '%(confdir)s/public',
'template_path': '%(confdir)s/nuts/templates',
'debug': False,
'erro... | 42 | 1,043 |
falcon | falcon/bench/nuts/nuts/app.py | .py | from pecan import make_app
# from .controllers import root
def create():
return make_app('controllers.root.RootController', logging={}, debug=False)
def setup_app(config):
return make_app(
config.app.root,
static_root=config.app.static_root,
template_path=config.app.template_path,
... | 19 | 494 |
falcon | falcon/bench/nuts/nuts/model/__init__.py | .py | from pecan import conf
def init_model():
"""
This is a stub method which is called at application startup time.
If you need to bind to a parse database configuration, set up tables or
ORM classes, or perform any database initialization, this is the
recommended place to do it.
For more inform... | 16 | 454 |
falcon | falcon/bench/nuts/nuts/tests/__init__.py | .py | import os
from unittest import TestCase
from pecan import set_config
from pecan.testing import load_test_app
__all__ = ('FunctionalTest',)
class FunctionalTest(TestCase):
"""
Used for functional tests where you need to test your
literal application and its integration with the framework.
"""
def... | 20 | 485 |
falcon | falcon/bench/nuts/nuts/tests/test_units.py | .py | from unittest import TestCase
class TestUnits(TestCase):
def test_units(self):
assert 5 * 5 == 25
| 7 | 112 |
falcon | falcon/bench/nuts/nuts/tests/test_functional.py | .py | from unittest import TestCase
from webtest import TestApp
from nuts.tests import FunctionalTest
class TestRootController(FunctionalTest):
def test_get(self):
response = self.app.get('/')
assert response.status_int == 200
def test_search(self):
response = self.app.post('/', params={'q'... | 21 | 669 |
falcon | falcon/bench/nuts/nuts/tests/config.py | .py | # Server Specific Configurations
server = {'port': '8080', 'host': '0.0.0.0'}
# Pecan Application Configurations
app = {
'root': 'nuts.controllers.root.RootController',
'modules': ['nuts'],
'static_root': '%(confdir)s/../../public',
'template_path': '%(confdir)s/../templates',
'debug': True,
'e... | 20 | 518 |
falcon | falcon/bench/nuts/nuts/controllers/root.py | .py | import random
import pecan
from pecan import expose, response, request
_body = pecan.x_test_body
_headers = pecan.x_test_headers
class TestController:
def __init__(self, account_id):
self.account_id = account_id
@expose(content_type='text/plain')
def test(self):
user_agent = request.he... | 37 | 787 |
falcon | falcon/util/misc.py | .py | # Copyright 2013 by Rackspace Hosting, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed t... | 556 | 18,338 |
falcon | falcon/util/mediatypes.py | .py | # Copyright 2023-2026 by Vytautas Liuolia.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 330 | 11,833 |
falcon | falcon/util/__init__.py | .py | """General utilities.
This package includes multiple modules that implement utility functions
and classes that are useful to both apps and the Falcon framework
itself.
All utilities in the `structures`, `misc`, and `time` modules are
imported directly into the front-door `falcon` module for convenience::
import ... | 110 | 3,595 |
falcon | falcon/util/sync.py | .py | from __future__ import annotations
import asyncio
from collections.abc import Awaitable
from concurrent.futures import ThreadPoolExecutor
from functools import partial
from functools import wraps
import inspect
import os
from typing import Any, Callable, cast, TypeVar
from falcon.util import deprecation
__all__ = (
... | 289 | 10,343 |
falcon | falcon/util/structures.py | .py | # Copied from the Requests library by Kenneth Reitz et al.
#
# Copyright 2013 Kenneth Reitz
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/... | 344 | 11,583 |
falcon | falcon/util/time.py | .py | """Time and date utilities.
This module provides utility functions and classes for dealing with
times and dates. These functions are hoisted into the `falcon` module
for convenience::
import falcon
tz = falcon.TimezoneGMT()
"""
from __future__ import annotations
import datetime
from .deprecation import de... | 74 | 1,797 |
falcon | falcon/util/deprecation.py | .py | # Copyright 2013 by Rackspace Hosting, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed t... | 120 | 4,161 |
falcon | falcon/util/uri.py | .py | # Copyright 2013 by Rackspace Hosting, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed t... | 575 | 21,026 |
falcon | falcon/util/reader.py | .py | # Copyright 2019-2026 by Vytautas Liuolia.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 421 | 14,656 |
falcon | falcon/routing/static.py | .py | from __future__ import annotations
import asyncio
from datetime import datetime
from datetime import timezone
from functools import partial
import io
import os
from pathlib import Path
import re
from re import Pattern
from typing import Any, ClassVar, IO, TYPE_CHECKING
import falcon
from falcon.typing import Readable... | 339 | 12,625 |
falcon | falcon/routing/util.py | .py | # Copyright 2013 by Rackspace Hosting, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed t... | 139 | 5,006 |
falcon | falcon/routing/__init__.py | .py | # Copyright 2013 by Rackspace Hosting, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed t... | 51 | 1,740 |
falcon | falcon/routing/compiled.py | .py | # Copyright 2013 by Richard Olsson
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 1,252 | 48,239 |
falcon | falcon/routing/converters.py | .py | # Copyright 2017 by Rackspace Hosting, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed t... | 259 | 7,816 |
graphene | setup.py | .py | import ast
import codecs
import re
import sys
from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand
_version_re = re.compile(r"VERSION\s+=\s+(.*)")
with open("graphene/__init__.py", "rb") as f:
version = ast.literal_eval(_version_re.search(f.read().decode("utf-8")).g... | 97 | 2,667 |
graphene | graphene/__init__.py | .py | from .pyutils.version import get_version
from .relay import (
BaseGlobalIDType,
ClientIDMutation,
Connection,
ConnectionField,
DefaultGlobalIDType,
GlobalID,
Node,
PageInfo,
SimpleGlobalIDType,
UUIDGlobalIDType,
is_node,
)
from .types import (
ID,
UUID,
Argument,
... | 99 | 1,558 |
graphene | graphene/pyutils/version.py | .py | import datetime
import os
import subprocess
def get_version(version=None):
"Returns a PEP 440-compliant version number from VERSION."
version = get_complete_version(version)
# Now build the two parts of the version number:
# main = X.Y[.Z]
# sub = .devN - for pre-alpha releases
# | {a|b|r... | 77 | 2,415 |
graphene | graphene/tests/issues/test_425.py | .py | # https://github.com/graphql-python/graphene/issues/425
# Adapted for Graphene 2.0
from graphene.types.enum import Enum, EnumOptions
from graphene.types.inputobjecttype import InputObjectType
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
# ObjectType
class SpecialOptions(ObjectTypeOptions):
... | 118 | 3,101 |
graphene | graphene/tests/issues/test_490.py | .py | # https://github.com/graphql-python/graphene/issues/313
import graphene
class Query(graphene.ObjectType):
some_field = graphene.String(from_=graphene.String(name="from"))
def resolve_some_field(self, info, from_=None):
return from_
def test_issue():
query_string = """
query myQuery {
... | 25 | 516 |
graphene | graphene/tests/issues/test_356.py | .py | # https://github.com/graphql-python/graphene/issues/356
from pytest import raises
import graphene
from graphene import relay
class SomeTypeOne(graphene.ObjectType):
pass
class SomeTypeTwo(graphene.ObjectType):
pass
class MyUnion(graphene.Union):
class Meta:
types = (SomeTypeOne, SomeTypeTwo)... | 34 | 698 |
graphene | graphene/tests/issues/test_1419.py | .py | import pytest
from ...types.base64 import Base64
from ...types.datetime import Date, DateTime
from ...types.decimal import Decimal
from ...types.generic import GenericScalar
from ...types.json import JSONString
from ...types.objecttype import ObjectType
from ...types.scalars import ID, BigInt, Boolean, Float, Int, Str... | 54 | 1,585 |
graphene | graphene/tests/issues/test_1394.py | .py | from ...types import ObjectType, Schema, String, NonNull
class Query(ObjectType):
hello = String(input=NonNull(String))
def resolve_hello(self, info, input):
if input == "nothing":
return None
return f"Hello {input}!"
schema = Schema(query=Query)
def test_required_input_provid... | 37 | 947 |
graphene | graphene/tests/issues/test_720.py | .py | # https://github.com/graphql-python/graphene/issues/720
# InputObjectTypes overwrite the "fields" attribute of the provided
# _meta object, so even if dynamic fields are provided with a standard
# InputObjectTypeOptions, they are ignored.
import graphene
class MyInputClass(graphene.InputObjectType):
@classmethod... | 45 | 1,197 |
graphene | graphene/tests/issues/test_956.py | .py | import graphene
def test_issue():
options = {"description": "This my enum", "deprecation_reason": "For the funs"}
new_enum = graphene.Enum("MyEnum", [("some", "data")], **options)
assert new_enum._meta.description == options["description"]
assert new_enum._meta.deprecation_reason == options["deprecati... | 9 | 332 |
graphene | graphene/tests/issues/test_313.py | .py | # https://github.com/graphql-python/graphene/issues/313
import graphene
class Query(graphene.ObjectType):
rand = graphene.String()
class Success(graphene.ObjectType):
yeah = graphene.String()
class Error(graphene.ObjectType):
message = graphene.String()
class CreatePostResult(graphene.Union):
c... | 58 | 1,106 |
graphene | graphene/tests/issues/test_1293.py | .py | # https://github.com/graphql-python/graphene/issues/1293
from datetime import datetime, timezone
import graphene
from graphql.utilities import print_schema
class Filters(graphene.InputObjectType):
datetime_after = graphene.DateTime(
required=False,
default_value=datetime.fromtimestamp(1434549820... | 42 | 1,066 |
graphene | graphene/tests/issues/test_881.py | .py | import pickle
from ...types.enum import Enum
class PickleEnum(Enum):
# is defined outside of test because pickle unable to dump class inside ot pytest function
A = "a"
B = 1
def test_enums_pickling():
a = PickleEnum.A
pickled = pickle.dumps(a)
restored = pickle.loads(pickled)
assert typ... | 28 | 663 |
graphene | graphene/relay/mutation.py | .py | import re
from ..types import Field, InputObjectType, String
from ..types.mutation import Mutation
from ..utils.thenables import maybe_thenable
class ClientIDMutation(Mutation):
class Meta:
abstract = True
@classmethod
def __init_subclass_with_meta__(
cls, output=None, input_fields=None,... | 67 | 2,213 |
graphene | graphene/relay/__init__.py | .py | from .node import Node, is_node, GlobalID
from .mutation import ClientIDMutation
from .connection import Connection, ConnectionField, PageInfo
from .id_type import (
BaseGlobalIDType,
DefaultGlobalIDType,
SimpleGlobalIDType,
UUIDGlobalIDType,
)
__all__ = [
"BaseGlobalIDType",
"ClientIDMutation"... | 24 | 501 |
graphene | graphene/relay/id_type.py | .py | from graphql_relay import from_global_id, to_global_id
from ..types import ID, UUID
from ..types.base import BaseType
from typing import Type
class BaseGlobalIDType:
"""
Base class that define the required attributes/method for a type.
"""
graphene_type: Type[BaseType] = ID
@classmethod
de... | 88 | 2,247 |
graphene | graphene/relay/connection.py | .py | import re
from collections.abc import Iterable
from functools import partial
from typing import Type
from graphql_relay import connection_from_array
from ..types import Boolean, Enum, Int, Interface, List, NonNull, Scalar, String, Union
from ..types.field import Field
from ..types.objecttype import ObjectType, Object... | 201 | 6,539 |
graphene | graphene/relay/node.py | .py | from functools import partial
from inspect import isclass
from ..types import Field, Interface, ObjectType
from ..types.interface import InterfaceOptions
from ..types.utils import get_type
from .id_type import BaseGlobalIDType, DefaultGlobalIDType
def is_node(objecttype):
"""
Check if the given objecttype ha... | 136 | 4,359 |
graphene | graphene/relay/tests/test_mutation_async.py | .py | from pytest import mark
from graphene.types import ID, Field, ObjectType, Schema
from graphene.types.scalars import String
from graphene.relay.mutation import ClientIDMutation
from graphene.test import Client
class SharedFields(object):
shared = String()
class MyNode(ObjectType):
# class Meta:
# in... | 91 | 2,262 |
graphene | graphene/relay/tests/test_connection.py | .py | import re
from pytest import raises
from ...types import Argument, Field, Int, List, NonNull, ObjectType, Schema, String
from ..connection import (
Connection,
ConnectionField,
PageInfo,
ConnectionOptions,
get_edge_class,
)
from ..node import Node
class MyObject(ObjectType):
class Meta:
... | 319 | 9,327 |
graphene | graphene/relay/tests/test_node_custom.py | .py | from textwrap import dedent
from graphql import graphql_sync
from ...types import Interface, ObjectType, Schema
from ...types.scalars import Int, String
from ..node import Node
class CustomNode(Node):
class Meta:
name = "Node"
@staticmethod
def to_global_id(type_, id):
return id
@s... | 314 | 6,741 |
graphene | graphene/relay/tests/test_connection_query.py | .py | from pytest import mark
from graphql_relay.utils import base64
from ...types import ObjectType, Schema, String
from ..connection import Connection, ConnectionField, PageInfo
from ..node import Node
letter_chars = ["A", "B", "C", "D", "E"]
class Letter(ObjectType):
class Meta:
interfaces = (Node,)
... | 287 | 7,013 |
graphene | graphene/relay/tests/test_node.py | .py | import re
from textwrap import dedent
from graphql_relay import to_global_id
from ...types import ObjectType, Schema, String
from ..node import Node, is_node
class SharedNodeFields:
shared = String()
something_else = String()
def resolve_something_else(*_):
return "----"
class MyNode(ObjectTy... | 220 | 5,608 |
graphene | graphene/relay/tests/test_mutation.py | .py | from pytest import mark, raises
from ...types import (
ID,
Argument,
Field,
InputField,
InputObjectType,
NonNull,
ObjectType,
Schema,
)
from ...types.scalars import String
from ..mutation import ClientIDMutation
class SharedFields:
shared = String()
class MyNode(ObjectType):
... | 207 | 5,750 |
graphene | graphene/relay/tests/test_global_id.py | .py | from graphql_relay import to_global_id
from ...types import ID, NonNull, ObjectType, String
from ...types.definitions import GrapheneObjectType
from ..node import GlobalID, Node
class CustomNode(Node):
class Meta:
name = "Node"
class User(ObjectType):
class Meta:
interfaces = [CustomNode]
... | 59 | 1,566 |
graphene | graphene/relay/tests/test_connection_async.py | .py | from pytest import mark
from graphql_relay.utils import base64
from graphene.types import ObjectType, Schema, String
from graphene.relay.connection import Connection, ConnectionField, PageInfo
from graphene.relay.node import Node
letter_chars = ["A", "B", "C", "D", "E"]
class Letter(ObjectType):
class Meta:
... | 122 | 2,754 |
graphene | graphene/relay/tests/test_custom_global_id.py | .py | import re
from uuid import uuid4
from graphql import graphql_sync
from ..id_type import BaseGlobalIDType, SimpleGlobalIDType, UUIDGlobalIDType
from ..node import Node
from ...types import Int, ObjectType, Schema, String
class TestUUIDGlobalID:
def setup_method(self):
self.user_list = [
{"id"... | 326 | 10,349 |
graphene | graphene/validation/__init__.py | .py | from .depth_limit import depth_limit_validator
from .disable_introspection import DisableIntrospection
__all__ = ["DisableIntrospection", "depth_limit_validator"]
| 6 | 165 |
graphene | graphene/validation/disable_introspection.py | .py | from graphql import GraphQLError
from graphql.language import FieldNode
from graphql.validation import ValidationRule
from ..utils.is_introspection_key import is_introspection_key
class DisableIntrospection(ValidationRule):
def enter_field(self, node: FieldNode, *_args):
field_name = node.name.value
... | 17 | 539 |
graphene | graphene/validation/depth_limit.py | .py | # This is a Python port of https://github.com/stems/graphql-depth-limit
# which is licensed under the terms of the MIT license, reproduced below.
#
# -----------
#
# MIT License
#
# Copyright (c) 2017 Stem
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated... | 196 | 6,504 |
graphene | graphene/validation/tests/test_disable_introspection.py | .py | from graphql import parse, validate
from ...types import Schema, ObjectType, String
from ..disable_introspection import DisableIntrospection
class Query(ObjectType):
name = String(required=True)
@staticmethod
def resolve_name(root, info):
return "Hello world!"
schema = Schema(query=Query)
de... | 38 | 842 |
graphene | graphene/validation/tests/test_depth_limit_validator.py | .py | import re
from pytest import raises
from graphql import parse, get_introspection_query, validate
from ...types import Schema, ObjectType, Interface
from ...types import String, Int, List, Field
from ..depth_limit import depth_limit_validator
class PetType(Interface):
name = String(required=True)
class meta... | 255 | 4,885 |
graphene | graphene/utils/str_converters.py | .py | import re
# Adapted from this response in Stackoverflow
# http://stackoverflow.com/a/19053800/1072990
def to_camel_case(snake_str):
components = snake_str.split("_")
# We capitalize the first letter of each component except the first one
# with the 'capitalize' method and join them together.
return co... | 18 | 619 |
graphene | graphene/utils/resolve_only_args.py | .py | from functools import wraps
from typing_extensions import deprecated
@deprecated("This function is deprecated")
def resolve_only_args(func):
@wraps(func)
def wrapped_func(root, info, **args):
return func(root, **args)
return wrapped_func
| 12 | 261 |
graphene | graphene/utils/deduplicator.py | .py | from collections.abc import Mapping
def deflate(node, index=None, path=None):
if index is None:
index = {}
if path is None:
path = []
if node and "id" in node and "__typename" in node:
route = ",".join(path)
cache_key = ":".join([route, str(node["__typename"]), str(node["i... | 33 | 919 |
graphene | graphene/utils/module_loading.py | .py | from functools import partial
from importlib import import_module
def import_string(dotted_path, dotted_attributes=None):
"""
Import a dotted module path and return the attribute/class designated by the
last name in the path. When a dotted attribute path is also provided, the
dotted attribute path wou... | 46 | 1,587 |
graphene | graphene/utils/is_introspection_key.py | .py | def is_introspection_key(key):
# from: https://spec.graphql.org/June2018/#sec-Schema
# > All types and directives defined within a schema must not have a name which
# > begins with "__" (two underscores), as this is used exclusively
# > by GraphQL’s introspection system.
return str(key).startswith("... | 7 | 327 |
graphene | graphene/utils/subclass_with_meta.py | .py | from inspect import isclass
from .props import props
class SubclassWithMeta_Meta(type):
_meta = None
def __str__(cls):
if cls._meta:
return cls._meta.name
return cls.__name__
def __repr__(cls):
return f"<{cls.__name__} meta={repr(cls._meta)}>"
class SubclassWithMet... | 51 | 1,616 |
graphene | graphene/utils/orderedtype.py | .py | from functools import total_ordering
@total_ordering
class OrderedType:
creation_counter = 1
def __init__(self, _creation_counter=None):
self.creation_counter = _creation_counter or self.gen_counter()
@staticmethod
def gen_counter():
counter = OrderedType.creation_counter
Ord... | 40 | 1,221 |
graphene | graphene/utils/get_unbound_function.py | .py | def get_unbound_function(func):
if not getattr(func, "__self__", True):
return func.__func__
return func
| 5 | 121 |
graphene | graphene/utils/thenables.py | .py | """
This file is used mainly as a bridge for thenable abstractions.
"""
from inspect import isawaitable
def await_and_execute(obj, on_resolve):
async def build_resolve_async():
return on_resolve(await obj)
return build_resolve_async()
def maybe_thenable(obj, on_resolve):
"""
Execute a on_r... | 26 | 667 |
graphene | graphene/utils/dataloader.py | .py | from asyncio import (
gather,
ensure_future,
get_event_loop,
iscoroutine,
iscoroutinefunction,
)
from collections import namedtuple
from collections.abc import Iterable
from functools import partial
from typing import List
Loader = namedtuple("Loader", "key,future")
def iscoroutinefunctionorpart... | 281 | 9,010 |
graphene | graphene/utils/props.py | .py | class _OldClass:
pass
class _NewClass:
pass
_all_vars = set(dir(_OldClass) + dir(_NewClass))
def props(x):
return {
key: vars(x).get(key, getattr(x, key)) for key in dir(x) if key not in _all_vars
}
| 16 | 229 |
graphene | graphene/utils/deprecated.py | .py | from warnings import warn
def warn_deprecation(text: str):
warn(text, category=DeprecationWarning, stacklevel=2)
| 6 | 119 |
graphene | graphene/utils/crunch.py | .py | import json
from collections.abc import Mapping
def to_key(value):
return json.dumps(value)
def insert(value, index, values):
key = to_key(value)
if key not in index:
index[key] = len(values)
values.append(value)
return len(values) - 1
return index.get(key)
def flatten(da... | 36 | 756 |
graphene | graphene/utils/tests/test_trim_docstring.py | .py | from ..trim_docstring import trim_docstring
def test_trim_docstring():
class WellDocumentedObject:
"""
This object is very well-documented. It has multiple lines in its
description.
Multiple paragraphs too
"""
assert (
trim_docstring(WellDocumentedObject.__doc... | 23 | 568 |
graphene | graphene/utils/tests/test_dataloader.py | .py | from asyncio import gather
from collections import namedtuple
from functools import partial
from unittest.mock import Mock
from graphene.utils.dataloader import DataLoader
from pytest import mark, raises
from graphene import ObjectType, String, Schema, Field, List
CHARACTERS = {
"1": {"name": "Luke Skywalker", "... | 453 | 10,662 |
graphene | graphene/utils/tests/test_deprecated.py | .py | from .. import deprecated
from ..deprecated import warn_deprecation
def test_warn_deprecation(mocker):
mocker.patch.object(deprecated, "warn")
warn_deprecation("OH!")
deprecated.warn.assert_called_with("OH!", stacklevel=2, category=DeprecationWarning)
| 10 | 267 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.