Merge branch 'master' into pyproject

This commit is contained in:
Dulmandakh 2024-07-05 17:07:08 +08:00
commit 73c43b03eb
10 changed files with 14 additions and 29 deletions

View File

@ -1,2 +0,0 @@
[settings]
known_third_party = graphql,graphql_relay,promise,pytest,pyutils,setuptools,snapshottest,sphinx_graphene_theme

View File

@ -22,10 +22,7 @@ repos:
- id: pyupgrade - id: pyupgrade
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version. # Ruff version.
rev: v0.4.10 rev: v0.5.0
hooks: hooks:
- id: ruff
- id: ruff-format - id: ruff-format
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8

View File

@ -1,7 +0,0 @@
#!/bin/bash
# Install the required scripts with
# pip install autoflake autopep8 isort
autoflake ./examples/ ./graphene/ -r --remove-unused-variables --remove-all-unused-imports --in-place
autopep8 ./examples/ ./graphene/ -r --in-place --experimental --aggressive --max-line-length 120
isort -rc ./examples/ ./graphene/

View File

@ -1,4 +1,5 @@
import os import os
import sys
import sphinx_graphene_theme import sphinx_graphene_theme
@ -22,8 +23,6 @@ on_rtd = os.environ.get("READTHEDOCS", None) == "True"
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
# #
import os
import sys
sys.path.insert(0, os.path.abspath("..")) sys.path.insert(0, os.path.abspath(".."))

View File

@ -71,6 +71,6 @@ def get_git_changeset():
) )
timestamp = git_log.communicate()[0] timestamp = git_log.communicate()[0]
timestamp = datetime.datetime.utcfromtimestamp(int(timestamp)) timestamp = datetime.datetime.utcfromtimestamp(int(timestamp))
except: except Exception:
return None return None
return timestamp.strftime("%Y%m%d%H%M%S") return timestamp.strftime("%Y%m%d%H%M%S")

View File

@ -11,7 +11,7 @@ class BaseGlobalIDType:
Base class that define the required attributes/method for a type. Base class that define the required attributes/method for a type.
""" """
graphene_type = ID # type: Type[BaseType] graphene_type: Type[BaseType] = ID
@classmethod @classmethod
def resolve_global_id(cls, info, global_id): def resolve_global_id(cls, info, global_id):

View File

@ -1,4 +1,3 @@
# flake8: noqa
from graphql import GraphQLResolveInfo as ResolveInfo from graphql import GraphQLResolveInfo as ResolveInfo
from .argument import Argument from .argument import Argument

View File

@ -1,17 +1,17 @@
from typing import Type from typing import Type, Optional
from ..utils.subclass_with_meta import SubclassWithMeta, SubclassWithMeta_Meta from ..utils.subclass_with_meta import SubclassWithMeta, SubclassWithMeta_Meta
from ..utils.trim_docstring import trim_docstring from ..utils.trim_docstring import trim_docstring
class BaseOptions: class BaseOptions:
name = None # type: str name: Optional[str] = None
description = None # type: str description: Optional[str] = None
_frozen = False # type: bool _frozen: bool = False
def __init__(self, class_type): def __init__(self, class_type: Type):
self.class_type = class_type # type: Type self.class_type: Type = class_type
def freeze(self): def freeze(self):
self._frozen = True self._frozen = True

View File

@ -121,8 +121,7 @@ class Float(Scalar):
""" """
@staticmethod @staticmethod
def coerce_float(value): def coerce_float(value: Any) -> float:
# type: (Any) -> float
try: try:
return float(value) return float(value)
except ValueError: except ValueError:

View File

@ -9,7 +9,7 @@ from collections import namedtuple
from collections.abc import Iterable from collections.abc import Iterable
from functools import partial from functools import partial
from typing import List # flake8: noqa from typing import List
Loader = namedtuple("Loader", "key,future") Loader = namedtuple("Loader", "key,future")
@ -62,7 +62,7 @@ class DataLoader(object):
self.get_cache_key = get_cache_key or (lambda x: x) self.get_cache_key = get_cache_key or (lambda x: x)
self._cache = cache_map if cache_map is not None else {} self._cache = cache_map if cache_map is not None else {}
self._queue = [] # type: List[Loader] self._queue: List[Loader] = []
@property @property
def loop(self): def loop(self):