Skip to content

Commit

Permalink
chore: switch to isort from reorder python imports
Browse files Browse the repository at this point in the history
- [x] keep it simple with just `--profile black` argument
- [x] update pull_request_template when asking for python-dateutil version
  - some engineers don't know to prefix `dateutil` with `python-`

This is a premptive strike on sigmavirus24#1172 fix

Signed-off-by: jmeridth <jmeridth@gmail.com>
  • Loading branch information
jmeridth committed Mar 21, 2024
1 parent 15df624 commit b541577
Show file tree
Hide file tree
Showing 90 changed files with 207 additions and 219 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Please provide:

- The version of pip you used to install github3.py

- The version of github3.py, requests, uritemplate, and dateutil installed
- The version of github3.py, requests, uritemplate, and python-dateutil installed

## Minimum Reproducible Example

Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ repos:
- id: trailing-whitespace
types: [text]
stages: [commit, push, manual]
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.12.0
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: reorder-python-imports
args: [--application-directories, '.:src', --py37-plus]
- id: isort
args: [--profile, black]
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,6 @@ exclude = [
"^docs/",
"^tests/",
]

[tool.isort]
profile = "black"
26 changes: 13 additions & 13 deletions src/github3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
:license: Modified BSD, see LICENSE for more details
"""
from .__about__ import __author__
from .__about__ import __author_email__
from .__about__ import __copyright__
from .__about__ import __license__
from .__about__ import __package_name__
from .__about__ import __title__
from .__about__ import __url__
from .__about__ import __version__
from .__about__ import __version_info__
from .api import enterprise_login
from .api import login
from .__about__ import (
__author__,
__author_email__,
__copyright__,
__license__,
__package_name__,
__title__,
__url__,
__version__,
__version_info__,
)
from .api import enterprise_login, login
from .exceptions import GitHubError
from .github import GitHub
from .github import GitHubEnterprise
from .github import GitHub, GitHubEnterprise

__all__ = (
"GitHub",
Expand Down
3 changes: 1 addition & 2 deletions src/github3/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
:license: Modified BSD, see LICENSE for more details
"""
from .github import GitHub
from .github import GitHubEnterprise
from .github import GitHub, GitHubEnterprise

gh = GitHub()

Expand Down
3 changes: 1 addition & 2 deletions src/github3/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

import jwt

from . import models
from . import users
from . import models, users

TEN_MINUTES_AS_SECONDS = 10 * 60
DEFAULT_JWT_TOKEN_EXPIRATION = TEN_MINUTES_AS_SECONDS
Expand Down
3 changes: 1 addition & 2 deletions src/github3/checks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""This module contains all the classes relating to Checks."""
from json import dumps

from . import decorators
from . import models
from . import decorators, models


class CheckPullRequest(models.GitHubCore):
Expand Down
3 changes: 1 addition & 2 deletions src/github3/gists/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
See also: http://developer.github.com/v3/gists/
"""
from .gist import Gist
from .gist import ShortGist
from .gist import Gist, ShortGist

__all__ = ("Gist", "ShortGist")
4 changes: 1 addition & 3 deletions src/github3/gists/comment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Module containing the logic for a GistComment."""
from .. import decorators
from .. import models
from .. import users
from .. import decorators, models, users


class GistComment(models.GitHubCore):
Expand Down
5 changes: 2 additions & 3 deletions src/github3/gists/gist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
import typing as t
from json import dumps

from .. import models, users
from ..decorators import requires_auth
from . import comment
from . import file as gistfile
from . import history
from .. import models
from .. import users
from ..decorators import requires_auth


class _Gist(models.GitHubCore):
Expand Down
3 changes: 1 addition & 2 deletions src/github3/gists/history.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Module containing the GistHistory object."""
from .. import models
from .. import users
from .. import models, users


class GistHistory(models.GitHubCore):
Expand Down
44 changes: 21 additions & 23 deletions src/github3/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,27 @@

import uritemplate # type: ignore

from . import apps
from . import auths
from . import decorators
from . import events
from . import gists
from . import issues
from . import licenses
from . import models
from . import notifications
from . import orgs
from . import projects
from . import pulls
from . import search
from . import session
from . import structs
from . import users
from . import utils
from .decorators import requires_app_credentials
from .decorators import requires_auth
from .decorators import requires_basic_auth
from .repos import invitation
from .repos import repo

from . import (
apps,
auths,
decorators,
events,
gists,
issues,
licenses,
models,
notifications,
orgs,
projects,
pulls,
search,
session,
structs,
users,
utils,
)
from .decorators import requires_app_credentials, requires_auth, requires_basic_auth
from .repos import invitation, repo

_pubsub_re = re.compile(
r"https?://[\w\d\-\.\:]+/\w[\w-]+\w/[\w\._-]+/events/\w+"
Expand Down
3 changes: 1 addition & 2 deletions src/github3/issues/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
See also: http://developer.github.com/v3/issues/
"""
from ..utils import timestamp_parameter
from .issue import Issue
from .issue import ShortIssue
from .issue import Issue, ShortIssue

__all__ = ["Issue", "ShortIssue"]

Expand Down
5 changes: 1 addition & 4 deletions src/github3/issues/comment.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"""Module with class(es) representing issue comments."""
from .. import decorators
from .. import models
from .. import users
from .. import utils
from .. import decorators, models, users, utils


class IssueComment(models.GitHubCore):
Expand Down
8 changes: 2 additions & 6 deletions src/github3/issues/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@

from uritemplate import URITemplate # type: ignore

from . import comment
from . import event
from . import label
from . import milestone
from .. import models
from .. import users
from .. import models, users
from ..decorators import requires_auth
from . import comment, event, label, milestone


class _Issue(models.GitHubCore):
Expand Down
2 changes: 1 addition & 1 deletion src/github3/issues/milestone.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from json import dumps

from . import label
from .. import users
from ..decorators import requires_auth
from ..models import GitHubCore
from . import label


class Milestone(GitHubCore):
Expand Down
4 changes: 1 addition & 3 deletions src/github3/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import dateutil.parser
import requests.compat

from . import exceptions
from . import session

from . import exceptions, session

if t.TYPE_CHECKING:
from . import structs
Expand Down
6 changes: 2 additions & 4 deletions src/github3/orgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

from uritemplate import URITemplate # type: ignore

from . import models
from . import users
from . import models, users
from .decorators import requires_auth
from .events import Event
from .projects import Project
from .repos import Repository
from .repos import ShortRepository
from .repos import Repository, ShortRepository

if t.TYPE_CHECKING:
from . import users as _users
Expand Down
5 changes: 1 addition & 4 deletions src/github3/projects.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
"""This module contains all the classes relating to projects."""
from json import dumps

from . import exceptions
from . import models
from . import pulls
from . import users
from . import exceptions, models, pulls, users
from .decorators import requires_auth
from .issues import issue

Expand Down
3 changes: 1 addition & 2 deletions src/github3/pulls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from uritemplate import URITemplate # type: ignore

from . import models
from . import users
from . import models, users
from .decorators import requires_auth
from .issues import Issue
from .issues.comment import IssueComment
Expand Down
4 changes: 1 addition & 3 deletions src/github3/repos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
See also: http://developer.github.com/v3/repos/
"""
from .repo import Repository
from .repo import ShortRepository
from .repo import StarredRepository
from .repo import Repository, ShortRepository, StarredRepository

__all__ = ("Repository", "ShortRepository", "StarredRepository")
5 changes: 2 additions & 3 deletions src/github3/repos/branch.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"""Implementation of a branch on a repository."""
import typing as t

from .. import decorators, models
from . import commit
from .. import decorators
from .. import models

if t.TYPE_CHECKING:
from .. import apps as tapps
from .. import users as tusers
from .. import orgs
from .. import users as tusers


class _Branch(models.GitHubCore):
Expand Down
3 changes: 1 addition & 2 deletions src/github3/repos/comment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This module contains the RepoComment class."""
from .. import models
from .. import users
from .. import models, users
from ..decorators import requires_auth


Expand Down
5 changes: 1 addition & 4 deletions src/github3/repos/commit.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""This module contains the RepoCommit classes."""
from .. import checks, git, models, users
from . import status
from .. import checks
from .. import git
from .. import models
from .. import users
from .comment import RepoComment


Expand Down
2 changes: 1 addition & 1 deletion src/github3/repos/comparison.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""This module contains the Comparison object."""
from . import commit
from .. import models
from . import commit


class Comparison(models.GitHubCore):
Expand Down
3 changes: 1 addition & 2 deletions src/github3/repos/contents.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This module contains the Contents object."""
from base64 import b64decode
from base64 import b64encode
from base64 import b64decode, b64encode
from json import dumps

from .. import models
Expand Down
3 changes: 1 addition & 2 deletions src/github3/repos/invitation.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Invitation related logic."""
from json import dumps

from .. import models
from .. import users
from .. import models, users
from ..decorators import requires_auth


Expand Down
4 changes: 1 addition & 3 deletions src/github3/repos/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

from uritemplate import URITemplate # type: ignore

from .. import models
from .. import users
from .. import utils
from .. import models, users, utils
from ..decorators import requires_auth
from ..exceptions import error_for

Expand Down
Loading

0 comments on commit b541577

Please sign in to comment.