Skip to content

Commit d53a102

Browse files
authored
Lint using Ruff (#1563)
* lint using Ruff * remove isort config, flake8 comments
1 parent fd9ecef commit d53a102

File tree

12 files changed

+15
-41
lines changed

12 files changed

+15
-41
lines changed

.isort.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ repos:
2222
- id: pyupgrade
2323
- repo: https://github.com/astral-sh/ruff-pre-commit
2424
# Ruff version.
25-
rev: v0.4.10
25+
rev: v0.5.0
2626
hooks:
27+
- id: ruff
2728
- id: ruff-format
28-
- repo: https://github.com/PyCQA/flake8
29-
rev: 5.0.4
30-
hooks:
31-
- id: flake8

bin/autolinter

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23

34
import sphinx_graphene_theme
45

@@ -22,8 +23,6 @@
2223
# add these directories to sys.path here. If the directory is relative to the
2324
# documentation root, use os.path.abspath to make it absolute, like shown here.
2425
#
25-
import os
26-
import sys
2726

2827
sys.path.insert(0, os.path.abspath(".."))
2928

graphene/pyutils/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ def get_git_changeset():
7171
)
7272
timestamp = git_log.communicate()[0]
7373
timestamp = datetime.datetime.utcfromtimestamp(int(timestamp))
74-
except:
74+
except Exception:
7575
return None
7676
return timestamp.strftime("%Y%m%d%H%M%S")

graphene/relay/id_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class BaseGlobalIDType:
1111
Base class that define the required attributes/method for a type.
1212
"""
1313

14-
graphene_type = ID # type: Type[BaseType]
14+
graphene_type: Type[BaseType] = ID
1515

1616
@classmethod
1717
def resolve_global_id(cls, info, global_id):

graphene/types/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# flake8: noqa
21
from graphql import GraphQLResolveInfo as ResolveInfo
32

43
from .argument import Argument

graphene/types/base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
from typing import Type
1+
from typing import Type, Optional
22

33
from ..utils.subclass_with_meta import SubclassWithMeta, SubclassWithMeta_Meta
44
from ..utils.trim_docstring import trim_docstring
55

66

77
class BaseOptions:
8-
name = None # type: str
9-
description = None # type: str
8+
name: Optional[str] = None
9+
description: Optional[str] = None
1010

11-
_frozen = False # type: bool
11+
_frozen: bool = False
1212

13-
def __init__(self, class_type):
14-
self.class_type = class_type # type: Type
13+
def __init__(self, class_type: Type):
14+
self.class_type: Type = class_type
1515

1616
def freeze(self):
1717
self._frozen = True

graphene/types/scalars.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ class Float(Scalar):
121121
"""
122122

123123
@staticmethod
124-
def coerce_float(value):
125-
# type: (Any) -> float
124+
def coerce_float(value: Any) -> float:
126125
try:
127126
return float(value)
128127
except ValueError:

graphene/utils/dataloader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from collections.abc import Iterable
1010
from functools import partial
1111

12-
from typing import List # flake8: noqa
12+
from typing import List
1313

1414
Loader = namedtuple("Loader", "key,future")
1515

@@ -62,7 +62,7 @@ def __init__(
6262
self.get_cache_key = get_cache_key or (lambda x: x)
6363

6464
self._cache = cache_map if cache_map is not None else {}
65-
self._queue = [] # type: List[Loader]
65+
self._queue: List[Loader] = []
6666

6767
@property
6868
def loop(self):

setup.cfg

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
[flake8]
2-
exclude = setup.py,docs/*,*/examples/*,graphene/pyutils/*,tests
3-
max-line-length = 120
4-
5-
# This is a specific ignore for Black+Flake8
6-
# source: https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#id1
7-
extend-ignore = E203
8-
91
[coverage:run]
102
omit = graphene/pyutils/*,*/tests/*,graphene/types/scalars.py
113

12-
[isort]
13-
known_first_party=graphene
14-
154
[bdist_wheel]
165
universal=1

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def run_tests(self):
5454
"coveralls>=4,<5",
5555
]
5656

57-
dev_requires = ["ruff==0.4.10", "flake8>=4,<5"] + tests_require
57+
dev_requires = ["ruff==0.5.0"] + tests_require
5858

5959
setup(
6060
name="graphene",

0 commit comments

Comments
 (0)