Skip to content

Commit 42c3b47

Browse files
BordaEnricoMi
andauthored
Replace flake8 with ruff (#2617)
Co-authored-by: Enrico Minack <[email protected]>
1 parent c5c83eb commit 42c3b47

18 files changed

+37
-43
lines changed

.isort.cfg

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

.pre-commit-config.yaml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ repos:
1111
rev: 22.10.0
1212
hooks:
1313
- id: black
14-
- repo: https://github.com/asottile/seed-isort-config
15-
rev: v2.2.0
16-
hooks:
17-
- id: seed-isort-config
18-
- repo: https://github.com/pre-commit/mirrors-isort
19-
rev: v5.10.1
20-
hooks:
21-
- id: isort
14+
2215
- repo: https://github.com/codespell-project/codespell
2316
rev: v2.2.1
2417
hooks:
@@ -33,7 +26,9 @@ repos:
3326
- id: pyupgrade
3427
args:
3528
- --py37-plus
36-
- repo: https://github.com/pycqa/flake8
37-
rev: 3.9.2
29+
30+
- repo: https://github.com/astral-sh/ruff-pre-commit
31+
rev: 'v0.0.278'
3832
hooks:
39-
- id: flake8
33+
- id: ruff
34+
args: ["--fix"]

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Ideally, changes should be made in logical commits and tests added to improve th
2525

2626
## Coding style
2727

28-
PyGithub adopts the black coding style and uses isort to sort imports.
28+
PyGithub adopts the black coding style.
2929

3030
To manually format the code:
3131
```bash

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# add these directories to sys.path here. If the directory is relative to the
3636
# documentation root, use os.path.abspath to make it absolute, like shown here.
3737
sys.path.insert(0, os.path.abspath(".."))
38-
from importlib.metadata import version # noqa: E402, isort:skip
38+
from importlib.metadata import version # noqa: E402
3939

4040
setupVersion = version("pygithub")
4141

github/GitReleaseAsset.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datetime import datetime
2-
from typing import Any, Dict, Union
2+
from typing import Any, Dict
33

44
from github.GithubObject import CompletableGithubObject
55
from github.NamedUser import NamedUser

github/GithubApp.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
from datetime import datetime
12
from typing import Any, Dict, List
23

3-
from datetime import datetime
44
from github.GithubObject import CompletableGithubObject
55
from github.NamedUser import NamedUser
66

github/GithubIntegration.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Union, Optional, Dict
1+
from typing import Dict, Optional, Union
22

33
from urllib3 import Retry
44

github/MainClass.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ from datetime import datetime
22
from io import BytesIO
33
from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union, overload
44

5-
from github.Auth import Auth
5+
from urllib3.util import Retry
6+
67
from github.AppAuthentication import AppAuthentication
78
from github.ApplicationOAuth import ApplicationOAuth
9+
from github.Auth import Auth
810
from github.AuthenticatedUser import AuthenticatedUser
911
from github.Commit import Commit
1012
from github.ContentFile import ContentFile
@@ -25,8 +27,6 @@ from github.RateLimit import RateLimit
2527
from github.Repository import Repository
2628
from github.Topic import Topic
2729

28-
from urllib3.util import Retry
29-
3030
TGithubObject = TypeVar("TGithubObject", bound=GithubObject)
3131

3232
DEFAULT_BASE_URL: str

github/Migration.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datetime import datetime
2-
from typing import Any, Dict, List, Optional, Union
2+
from typing import Any, Dict, List
33

44
from github.GithubObject import CompletableGithubObject
55
from github.NamedUser import NamedUser

github/Plan.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, Union
1+
from typing import Any, Dict
22

33
from github.GithubObject import NonCompletableGithubObject
44

github/Repository.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ from github.RepositoryAdvisory import RepositoryAdvisory
5454
from github.RepositoryAdvisoryCredit import RepositoryAdvisoryCredit
5555
from github.RepositoryAdvisoryVulnerability import (
5656
AdvisoryVulnerability,
57-
RepositoryAdvisoryVulnerability,
5857
)
5958
from github.RepositoryKey import RepositoryKey
6059
from github.RepositoryPreferences import RepositoryPreferences

github/SourceImport.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, Optional
1+
from typing import Any, Dict
22

33
from github.GithubObject import CompletableGithubObject
44

github/StatsContributor.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datetime import datetime
2-
from typing import Any, Dict, List, Optional
2+
from typing import Any, Dict, List
33

44
from github.GithubObject import NonCompletableGithubObject
55
from github.NamedUser import NamedUser

github/Team.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from typing import Any, Dict, Union
22

33
from github.GithubObject import CompletableGithubObject, _NotSetType
4+
from github.Membership import Membership
45
from github.NamedUser import NamedUser
56
from github.Organization import Organization
6-
from github.Membership import Membership
77
from github.PaginatedList import PaginatedList
88
from github.Permissions import Permissions
99
from github.Repository import Repository

github/Topic.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from datetime import datetime
2-
32
from typing import Any, Dict
43

54
from github.GithubObject import NonCompletableGithubObject

manage.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ function publish {
99
push
1010
}
1111

12-
function check {
13-
flake8
14-
}
15-
1612
function fix_headers {
1713
python scripts/fix_headers.py
1814
}

pyproject.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,25 @@ module = ["github.*"]
88
check_untyped_defs = true
99
disallow_untyped_defs = true
1010

11+
1112
[tool.black]
1213
# https://github.com/psf/black
1314
line-length = 120
1415
target-version = ['py37']
16+
17+
18+
[tool.ruff]
19+
line-length = 120
20+
target-version = "py37"
21+
# Enable Pyflakes `E` and `F` codes by default.
22+
select = [
23+
"E", "W", # see: https://pypi.org/project/pycodestyle
24+
"F", # see: https://pypi.org/project/pyflakes
25+
"I", # see: isort
26+
]
27+
ignore = [
28+
"E501",
29+
"E741",
30+
]
31+
ignore-init-module-imports = true
32+
unfixable = ["F401"]

tox.ini

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,3 @@ basepython = python3.8
3535
skip_install = true
3636
deps = -rrequirements.txt
3737
commands = sphinx-build doc build
38-
39-
[flake8]
40-
max-line-length = 120
41-
select = C,E,F,W
42-
ignore = E266, E501, W503

0 commit comments

Comments
 (0)