diff --git a/.dprint.json b/.dprint.json new file mode 100644 index 0000000..216deec --- /dev/null +++ b/.dprint.json @@ -0,0 +1,24 @@ +{ + "json": { + }, + "markdown": { + }, + "toml": { + }, + "ruff": { + }, + "excludes": [ + "**/.nox", + "**/.tox", + "**/.mypy_cache", + "**/.pytest_cache", + "**/.venv", + "**/*-lock.json" + ], + "plugins": [ + "https://plugins.dprint.dev/json-0.19.1.wasm", + "https://plugins.dprint.dev/markdown-0.16.3.wasm", + "https://plugins.dprint.dev/toml-0.6.0.wasm", + "https://plugins.dprint.dev/ruff-0.1.2.wasm" + ] +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index abb1b00..e2594bf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,7 @@ # Contributing Guide You will need: + - Python 3.7 or higher ## Getting started diff --git a/LICENSE.md b/LICENSE.md index de78be1..d6e8b2c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,13 +1,13 @@ - Copyright 2019 The Upside Travel Company LLC. All Rights Reserved. +Copyright 2019 The Upside Travel Company LLC. All Rights Reserved. - 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 +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 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/README.md b/README.md index 17d0561..e57cddf 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # ![Graphene Logo](http://graphene-python.org/favicon.png) graphene-pydantic [![Build status](https://circleci.com/gh/upsidetravel/graphene-pydantic.svg?style=svg)](https://circleci.com/gh/upsidetravel/graphene-pydantic) [![PyPI version](https://badge.fury.io/py/graphene-pydantic.svg)](https://badge.fury.io/py/graphene-pydantic) [![Coverage Status](https://coveralls.io/repos/upsidetravel/graphene-pydantic/badge.svg?branch=master&service=github)](https://coveralls.io/github/upsidetravel/graphene-pydantic?branch=master) - - A [Pydantic](https://pydantic-docs.helpmanual.io/) integration for [Graphene](http://graphene-python.org/). ## Installation @@ -127,12 +125,11 @@ class Person(PydanticObjectType): return self.first_name + ' ' + self.last_name ``` - ### Forward declarations and circular references `graphene_pydantic` supports forward declarations and circular references, but you will need to call the `resolve_placeholders()` method to ensure the types are fully updated before you execute a GraphQL query. For instance: -``` python +```python class NodeModel(BaseModel): id: int name: str @@ -177,7 +174,7 @@ Please see the [Contributing Guide](./CONTRIBUTING.md). Note that even though Pydantic is perfectly happy with fields that hold mappings (e.g. dictionaries), because [GraphQL's type system doesn't have them](https://graphql.org/learn/schema/) those fields can't be exported to Graphene types. For instance, this will fail with an error `Don't know how to handle mappings in Graphene`: -``` python +```python import typing from graphene_pydantic import PydanticObjectType @@ -195,7 +192,7 @@ class GraphQLPerson(PydanticObjectType): However, note that if you use `exclude_fields` or `only_fields` to exclude those values, there won't be a problem: -``` python +```python class GraphQLPerson(PydanticObjectType): class Meta: model = Person @@ -248,9 +245,7 @@ class Department(PydanticObjectType): model = DepartmentModel ``` -Otherwise GraphQL will throw an error similar to `"[GraphQLError('Abstract type -UnionOfManagerModelEmployeeModel must resolve to an Object type at runtime for -field Department.employees ..."` +Otherwise GraphQL will throw an error similar to `"[GraphQLError('Abstract type UnionOfManagerModelEmployeeModel must resolve to an Object type at runtime for field Department.employees ..."` ##### For unions between subclasses, you need to put the subclass first in the type annotation diff --git a/THIRD_PARTY_LICENSES.md b/THIRD_PARTY_LICENSES.md index 8ef5651..a1451db 100644 --- a/THIRD_PARTY_LICENSES.md +++ b/THIRD_PARTY_LICENSES.md @@ -1,4 +1,5 @@ [graphene](https://github.com/graphql-python/graphene) + ``` The MIT License (MIT) @@ -24,6 +25,7 @@ SOFTWARE. ``` [pydantic](https://github.com/samuelcolvin/pydantic) + ``` The MIT License (MIT) diff --git a/graphene_pydantic/inputobjecttype.py b/graphene_pydantic/inputobjecttype.py index 95f444d..01b7587 100644 --- a/graphene_pydantic/inputobjecttype.py +++ b/graphene_pydantic/inputobjecttype.py @@ -80,8 +80,8 @@ def __init_subclass_with_meta__( _meta=None, **options, ): - assert model and issubclass( - model, pydantic.BaseModel + assert ( + model and issubclass(model, pydantic.BaseModel) ), f'You need to pass a valid Pydantic model in {cls.__name__}.Meta, received "{model}"' assert isinstance( diff --git a/graphene_pydantic/objecttype.py b/graphene_pydantic/objecttype.py index 91f6bbd..1f36abd 100644 --- a/graphene_pydantic/objecttype.py +++ b/graphene_pydantic/objecttype.py @@ -71,8 +71,8 @@ def __init_subclass_with_meta__( _meta=None, **options, ): - assert model and issubclass( - model, pydantic.BaseModel + assert ( + model and issubclass(model, pydantic.BaseModel) ), f'You need to pass a valid Pydantic model in {cls.__name__}.Meta, received "{model}"' assert isinstance( diff --git a/pyproject.toml b/pyproject.toml index 99da963..4bf9ce7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,15 +10,15 @@ authors = [ ] license = "Apache-2.0" classifiers = [ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "Topic :: Software Development :: Libraries", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: Implementation :: PyPy", + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: PyPy", ] keywords = ["api", "graphql", "protocol", "rest", "relay", "graphene", "pydantic", "model"] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy