diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 70c773e90..5b889e021 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,10 +22,7 @@ repos: - id: pyupgrade - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.4.10 + rev: v0.5.0 hooks: + - id: ruff - id: ruff-format -- repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 - hooks: - - id: flake8 diff --git a/bin/autolinter b/bin/autolinter deleted file mode 100755 index 0fc3ccaee..000000000 --- a/bin/autolinter +++ /dev/null @@ -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/ diff --git a/docs/conf.py b/docs/conf.py index 75f515416..873531ae6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,5 @@ import os +import sys import sphinx_graphene_theme @@ -22,8 +23,6 @@ # 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. # -import os -import sys sys.path.insert(0, os.path.abspath("..")) diff --git a/graphene/pyutils/version.py b/graphene/pyutils/version.py index c5f893f55..1a3453e97 100644 --- a/graphene/pyutils/version.py +++ b/graphene/pyutils/version.py @@ -71,6 +71,6 @@ def get_git_changeset(): ) timestamp = git_log.communicate()[0] timestamp = datetime.datetime.utcfromtimestamp(int(timestamp)) - except: + except Exception: return None return timestamp.strftime("%Y%m%d%H%M%S") diff --git a/graphene/relay/id_type.py b/graphene/relay/id_type.py index fb5c30e72..8369a7517 100644 --- a/graphene/relay/id_type.py +++ b/graphene/relay/id_type.py @@ -11,7 +11,7 @@ class BaseGlobalIDType: Base class that define the required attributes/method for a type. """ - graphene_type = ID # type: Type[BaseType] + graphene_type: Type[BaseType] = ID @classmethod def resolve_global_id(cls, info, global_id): diff --git a/graphene/types/base.py b/graphene/types/base.py index 84cb377a2..063f0cd95 100644 --- a/graphene/types/base.py +++ b/graphene/types/base.py @@ -1,17 +1,17 @@ -from typing import Type +from typing import Type, Optional from ..utils.subclass_with_meta import SubclassWithMeta, SubclassWithMeta_Meta from ..utils.trim_docstring import trim_docstring class BaseOptions: - name = None # type: str - description = None # type: str + name: Optional[str] = None + description: Optional[str] = None - _frozen = False # type: bool + _frozen: bool = False - def __init__(self, class_type): - self.class_type = class_type # type: Type + def __init__(self, class_type: Type): + self.class_type: Type = class_type def freeze(self): self._frozen = True diff --git a/graphene/types/scalars.py b/graphene/types/scalars.py index a468bb3e6..8546bc85c 100644 --- a/graphene/types/scalars.py +++ b/graphene/types/scalars.py @@ -121,8 +121,7 @@ class Float(Scalar): """ @staticmethod - def coerce_float(value): - # type: (Any) -> float + def coerce_float(value: Any) -> float: try: return float(value) except ValueError: diff --git a/graphene/utils/dataloader.py b/graphene/utils/dataloader.py index b8f4a0cdd..a51398b24 100644 --- a/graphene/utils/dataloader.py +++ b/graphene/utils/dataloader.py @@ -62,7 +62,7 @@ def __init__( self.get_cache_key = get_cache_key or (lambda x: x) self._cache = cache_map if cache_map is not None else {} - self._queue = [] # type: List[Loader] + self._queue: List[Loader] = [] @property def loop(self): diff --git a/setup.cfg b/setup.cfg index db1ff1345..0608b0166 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,16 +1,5 @@ -[flake8] -exclude = setup.py,docs/*,*/examples/*,graphene/pyutils/*,tests -max-line-length = 120 - -# This is a specific ignore for Black+Flake8 -# source: https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#id1 -extend-ignore = E203 - [coverage:run] omit = graphene/pyutils/*,*/tests/*,graphene/types/scalars.py -[isort] -known_first_party=graphene - [bdist_wheel] universal=1 diff --git a/setup.py b/setup.py index 72377c7e1..5f949a7d2 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ def run_tests(self): "coveralls>=4,<5", ] -dev_requires = ["ruff==0.4.10", "flake8>=4,<5"] + tests_require +dev_requires = ["ruff==0.5.0"] + tests_require setup( name="graphene",