Skip to content

Commit

Permalink
Add dprint for formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rami Chowdhury committed Feb 18, 2024
1 parent 2a9dbea commit 310ca1e
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 32 deletions.
24 changes: 24 additions & 0 deletions .dprint.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Contributing Guide

You will need:

- Python 3.7 or higher

## Getting started
Expand Down
20 changes: 10 additions & 10 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -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.
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions THIRD_PARTY_LICENSES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[graphene](https://github.com/graphql-python/graphene)

```
The MIT License (MIT)
Expand All @@ -24,6 +25,7 @@ SOFTWARE.
```

[pydantic](https://github.com/samuelcolvin/pydantic)

```
The MIT License (MIT)
Expand Down
4 changes: 2 additions & 2 deletions graphene_pydantic/inputobjecttype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions graphene_pydantic/objecttype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down

0 comments on commit 310ca1e

Please sign in to comment.