Skip to content

Commit

Permalink
Switch to isort from reorder-python-imports
Browse files Browse the repository at this point in the history
* chore: switch to isort from reorder python imports

- [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 #1172 fix

Signed-off-by: jmeridth <jmeridth@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: add line-length to isort to match black

re-run black, hopefully get us to a non-conflict

Signed-off-by: jmeridth <jmeridth@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Use isort config to reduce churn

---------

Signed-off-by: jmeridth <jmeridth@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ian Stapleton Cordasco <graffatcolmingov@gmail.com>
  • Loading branch information
3 people committed Mar 21, 2024
1 parent 15df624 commit 442d783
Show file tree
Hide file tree
Showing 111 changed files with 212 additions and 129 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
7 changes: 3 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ 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
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,8 @@ exclude = [
"^docs/",
"^tests/",
]

[tool.isort]
profile = "black"
line_length = 78
force_single_line = true
1 change: 1 addition & 0 deletions src/github3/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The module that holds much of the metadata about github3.py."""

__package_name__ = "github3.py"
__title__ = "github3"
__author__ = "Ian Stapleton Cordasco"
Expand Down
1 change: 1 addition & 0 deletions src/github3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:license: Modified BSD, see LICENSE for more details
"""

from .__about__ import __author__
from .__about__ import __author_email__
from .__about__ import __copyright__
Expand Down
1 change: 1 addition & 0 deletions src/github3/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:license: Modified BSD, see LICENSE for more details
"""

from .github import GitHub
from .github import GitHubEnterprise

Expand Down
1 change: 1 addition & 0 deletions src/github3/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
https://developer.github.com/apps/building-github-apps/
"""

import time

import jwt
Expand Down
1 change: 1 addition & 0 deletions src/github3/auths.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the Authorization object."""

from .decorators import requires_basic_auth
from .models import GitHubCore

Expand Down
1 change: 1 addition & 0 deletions src/github3/checks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains all the classes relating to Checks."""

from json import dumps

from . import decorators
Expand Down
1 change: 1 addition & 0 deletions src/github3/decorators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module provides decorators to the rest of the library."""

import os
from functools import wraps
from io import BytesIO as StringIO
Expand Down
1 change: 1 addition & 0 deletions src/github3/events.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the classes related to Events."""

import copy

from . import models
Expand Down
1 change: 1 addition & 0 deletions src/github3/gists/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
See also: http://developer.github.com/v3/gists/
"""

from .gist import Gist
from .gist import ShortGist

Expand Down
1 change: 1 addition & 0 deletions src/github3/gists/comment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing the logic for a GistComment."""

from .. import decorators
from .. import models
from .. import users
Expand Down
1 change: 1 addition & 0 deletions src/github3/gists/file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing the GistFile object."""

from .. import models


Expand Down
7 changes: 4 additions & 3 deletions src/github3/gists/gist.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""This module contains the Gist, ShortGist, and GistFork objects."""

import typing as t
from json import dumps

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


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

from .. import models
from .. import users

Expand Down
1 change: 1 addition & 0 deletions src/github3/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
See also: http://developer.github.com/v3/git/
"""

import base64
from json import dumps

Expand Down
2 changes: 1 addition & 1 deletion src/github3/github.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the main interfaces to the API."""

import json
import re
import typing as t
Expand Down Expand Up @@ -28,7 +29,6 @@
from .repos import invitation
from .repos import repo


_pubsub_re = re.compile(
r"https?://[\w\d\-\.\:]+/\w[\w-]+\w/[\w\._-]+/events/\w+"
)
Expand Down
1 change: 1 addition & 0 deletions src/github3/issues/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
See also: http://developer.github.com/v3/issues/
"""

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

from .. import decorators
from .. import models
from .. import users
Expand Down
1 change: 1 addition & 0 deletions src/github3/issues/event.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Issue events logic."""

from .. import users
from ..models import GitHubCore

Expand Down
7 changes: 4 additions & 3 deletions src/github3/issues/issue.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
"""Module containing the Issue logic."""

from json import dumps

from uritemplate import URITemplate # type: ignore

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


class _Issue(models.GitHubCore):
Expand Down
1 change: 1 addition & 0 deletions src/github3/issues/label.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing the logic for labels."""

from json import dumps

from ..decorators import requires_auth
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
1 change: 1 addition & 0 deletions src/github3/licenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
See also: https://developer.github.com/v3/licenses/
"""

import base64

from . import models
Expand Down
2 changes: 1 addition & 1 deletion src/github3/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module provides the basic models used in github3.py."""

import json as jsonlib
import logging
import typing as t
Expand All @@ -9,7 +10,6 @@
from . import exceptions
from . import session


if t.TYPE_CHECKING:
from . import structs

Expand Down
1 change: 1 addition & 0 deletions src/github3/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
See also: http://developer.github.com/v3/activity/notifications/
"""

from json import dumps

from . import models
Expand Down
1 change: 1 addition & 0 deletions src/github3/orgs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains all of the classes related to organizations."""

import typing as t
from json import dumps

Expand Down
1 change: 1 addition & 0 deletions src/github3/projects.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains all the classes relating to projects."""

from json import dumps

from . import exceptions
Expand Down
1 change: 1 addition & 0 deletions src/github3/pulls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains all the classes relating to pull requests."""

from json import dumps

from uritemplate import URITemplate # type: ignore
Expand Down
1 change: 1 addition & 0 deletions src/github3/repos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
See also: http://developer.github.com/v3/repos/
"""

from .repo import Repository
from .repo import ShortRepository
from .repo import StarredRepository
Expand Down
9 changes: 6 additions & 3 deletions src/github3/repos/branch.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""Implementation of a branch on a repository."""

import typing as t

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

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 Expand Up @@ -603,7 +604,9 @@ class ProtectionRestrictions(models.GitHubCore):
"""

def _update_attributes(self, protection):
from .. import apps, orgs, users
from .. import apps
from .. import orgs
from .. import users

self._api = protection["url"]
self.users_url = protection["users_url"]
Expand Down
1 change: 1 addition & 0 deletions src/github3/repos/comment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the RepoComment class."""

from .. import models
from .. import users
from ..decorators import requires_auth
Expand Down
3 changes: 2 additions & 1 deletion src/github3/repos/commit.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""This module contains the RepoCommit classes."""
from . import status

from .. import checks
from .. import git
from .. import models
from .. import users
from . import status
from .comment import RepoComment


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

from .. import models
from . import commit


class Comparison(models.GitHubCore):
Expand Down
1 change: 1 addition & 0 deletions src/github3/repos/contents.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the Contents object."""

from base64 import b64decode
from base64 import b64encode
from json import dumps
Expand Down
1 change: 1 addition & 0 deletions src/github3/repos/deployment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The module containing deployment logic."""

from .. import users
from ..models import GitHubCore

Expand Down
1 change: 1 addition & 0 deletions src/github3/repos/hook.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains only the Hook object for GitHub's Hook API."""

from json import dumps

from ..decorators import requires_auth
Expand Down
1 change: 1 addition & 0 deletions src/github3/repos/invitation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Invitation related logic."""

from json import dumps

from .. import models
Expand Down
1 change: 1 addition & 0 deletions src/github3/repos/issue_import.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains the logic for GitHub's import issue API."""

from .. import models


Expand Down
1 change: 1 addition & 0 deletions src/github3/repos/pages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""GitHub Pages related logic."""

from .. import models


Expand Down
1 change: 1 addition & 0 deletions src/github3/repos/release.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Release logic for the GitHub API."""

import json

from uritemplate import URITemplate # type: ignore
Expand Down

0 comments on commit 442d783

Please sign in to comment.