GithubHelp home page GithubHelp logo

graphene-stubs's People

Contributors

ckarnell avatar ericborczuk avatar jasonoro avatar marktengi avatar minznerjosh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphene-stubs's Issues

[Master branch] Incorrect "No field with name defined" when using namespace

Hi,

I was messing around with the master branch and noticed the following:

import graphene
class TestQuery(graphene.ObjectType):
    field = graphene.Field(String)

    @staticmethod
    def resolve_field(_: None, __: graphene.ResolveInfo) -> Optional[str]:
        return 'hi'

This however returns the following error:

main:9: error: No field with name "field" defined

When changing the graphene.Field to from graphene import Field and then just use Field it works fine.

Here's a test case (that currently fails) so you can reproduce it in pytest:

[case test_field_resolve_with_namespace]
from graphene import String, ResolveInfo
import graphene


class TestQuery(graphene.ObjectType):
    field = graphene.Field(String)

    @staticmethod
    def resolve_field(_: None, __: ResolveInfo) -> Optional[str]:
        return 'hi'

Schema(query=TestQuery)

[out]
Success: no issues found in 1 source file

Using one `ObjectType` as the base of another crashes mypy

Using one type as the base class of another is valid in graphene, but it causes an error to be thrown by our plugin.

Minimal repro:

from graphene import ObjectType, String, Field, NonNull

class User(ObjectType):
    id = Field(NonNull(String))

class MoreSpecificUser(User):
    id = Field(NonNull(String))

It causes a StopIteration error to be thrown by this code in the plugin:

    graphene_base = next(
        base for base in type_info.bases if base.type.fullname in (GRAPHENE_OBJECTTYPE_NAME, GRAPHENE_INTERFACE_NAME)
    )

Scalar fields with resolvers don't work

According to the graphene documentation, the following is the same:

class Person(graphene.ObjectType):
    name = graphene.String()

# Is equivalent to:
class Person(graphene.ObjectType):
    name = graphene.Field(graphene.String)

However, graphene-stubs doesn't allow the above example when using resolvers.

from graphene import ObjectType, String
from graphql import ResolveInfo


class Person(ObjectType):
    name = String()

    @staticmethod
    def resolve_name(_, __: ResolveInfo) -> str:
        return "Test"
$ mypy test.py
test.py:11: error: No field with name "name" defined
Found 1 error in 1 file (checked 1 source file)

When wrapping it in a Field it's fine. Is this a known limitation or would this classify as a bug that can be fixed?

Versioning: `dist/`, `*.egg-info/`, `build/` directories?

Hi!

Is there any context to why the dist/ directory is being versioned?

Normally:

  • That wouldn't be the case (they'd be under .gitignore), but there may be some special reason to?
  • PyPI would store the .whl / .tar.gz's and they could be built at any time via the git tag

Thoughts? If they're not needed: I could provide information on what I think you could do

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.