Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isort #135

Merged
merged 3 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test_tap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ jobs:
run: |
poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Check formatting with black
- name: Check formatting with black and isort
run: |
poetry run black --check .
poetry run isort --check .
- name: Check typing annotations with mypy
run: |
poetry run mypy . --ignore-missing-imports
Expand Down
20 changes: 19 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ types-beautifulsoup4 = "^4.11.1"
types-requests = "^2.25.6"
types-python-dateutil = "^2.8.9"
requests-cache = "^0.9.1"
isort = "^5.10.1"

[[tool.mypy.overrides]]
module = [
Expand Down
9 changes: 4 additions & 5 deletions tap_github/client.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
"""REST client handling, including GitHubStream base class."""

import collections
import inspect
import re
from types import FrameType
from typing import Any, Dict, Iterable, List, Optional, cast
from urllib.parse import parse_qs, urlparse

import inspect
import requests

from dateutil.parser import parse
from urllib.parse import parse_qs, urlparse

from nested_lookup import nested_lookup

from singer_sdk.exceptions import FatalAPIError, RetriableAPIError
from singer_sdk.helpers.jsonpath import extract_jsonpath
from singer_sdk.streams import GraphQLStream, RESTStream
Expand Down
2 changes: 1 addition & 1 deletion tap_github/organization_streams.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""User Stream types classes for tap-github."""

from typing import Dict, List, Optional, Iterable, Any
from typing import Any, Dict, Iterable, List, Optional

from singer_sdk import typing as th # JSON Schema typing helpers

Expand Down
9 changes: 4 additions & 5 deletions tap_github/repository_streams.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
"""Repository Stream types classes for tap-github."""

from typing import Any, Dict, Iterable, List, Optional, Tuple
from urllib.parse import parse_qs, urlparse

import requests
from dateutil.parser import parse
from singer_sdk import typing as th # JSON Schema typing helpers
from singer_sdk.helpers.jsonpath import extract_jsonpath

from dateutil.parser import parse
from urllib.parse import parse_qs, urlparse

from tap_github.client import GitHubGraphqlStream, GitHubRestStream
from tap_github.schema_objects import (
user_object,
label_object,
reactions_object,
milestone_object,
reactions_object,
user_object,
)
from tap_github.scraping import scrape_dependents

Expand Down
7 changes: 3 additions & 4 deletions tap_github/scraping.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
Inspired by https://github.com/dogsheep/github-to-sqlite/pull/70
"""
import logging
import requests
import time

from typing import Any, Dict, Iterable, Optional
from urllib.parse import urlparse

import requests


def scrape_dependents(
response: requests.Response, logger: Optional[logging.Logger] = None
Expand Down Expand Up @@ -36,8 +36,7 @@ def scrape_dependents(

def _scrape_dependents(url: str, logger: logging.Logger) -> Iterable[Dict[str, Any]]:
# Optional dependency:
from bs4 import BeautifulSoup
from bs4 import Tag
from bs4 import BeautifulSoup, Tag

s = requests.Session()

Expand Down
20 changes: 8 additions & 12 deletions tap_github/streams.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
from enum import Enum
from typing import Type, Set, List
from typing import List, Set, Type

from singer_sdk.streams.core import Stream

from tap_github.organization_streams import (
OrganizationStream,
TeamMembersStream,
TeamRolesStream,
TeamsStream,
)
from tap_github.repository_streams import (
AnonymousContributorsStream,
AssigneesStream,
Expand Down Expand Up @@ -36,17 +42,7 @@
WorkflowRunsStream,
WorkflowsStream,
)
from tap_github.user_streams import (
StarredStream,
UserContributedToStream,
UserStream,
)
from tap_github.organization_streams import (
OrganizationStream,
TeamMembersStream,
TeamRolesStream,
TeamsStream,
)
from tap_github.user_streams import StarredStream, UserContributedToStream, UserStream


class Streams(Enum):
Expand Down
5 changes: 2 additions & 3 deletions tap_github/tap.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""GitHub tap class."""

from typing import List

import os
import logging
import os
from typing import List

from singer_sdk import Stream, Tap
from singer_sdk import typing as th # JSON schema typing helpers
Expand Down
5 changes: 3 additions & 2 deletions tap_github/tests/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import logging
import datetime
import logging
import os
import sys

import pytest

from ..utils.filter_stdout import FilterStdOutput

# Filter out singer output during tests
Expand Down
10 changes: 4 additions & 6 deletions tap_github/tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
"""Tests standard tap features using the built-in SDK tests library."""
import os
import logging

import os
from unittest import mock
from unittest.mock import patch

from tap_github.utils.filter_stdout import nostdout

from .fixtures import alternative_sync_chidren
from singer_sdk.testing import get_standard_tap_tests

from tap_github.tap import TapGitHub
from tap_github.utils.filter_stdout import nostdout

from .fixtures import (
alternative_sync_chidren,
organization_list_config,
repo_list_config,
search_config,
username_list_config,
organization_list_config,
)


Expand Down
8 changes: 4 additions & 4 deletions tap_github/tests/test_tap.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os
import logging
import pytest
import os
from typing import Optional

from unittest.mock import patch

from singer_sdk.helpers._singer import Catalog
import pytest
from singer_sdk.helpers import _catalog as cat_helpers
from singer_sdk.helpers._singer import Catalog

from tap_github.tap import TapGitHub

from .fixtures import alternative_sync_chidren, repo_list_config, username_list_config
Expand Down
2 changes: 1 addition & 1 deletion tap_github/user_streams.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""User Stream types classes for tap-github."""

import re
from typing import Dict, List, Optional, Iterable, Any
from typing import Any, Dict, Iterable, List, Optional

from singer_sdk import typing as th # JSON Schema typing helpers
from singer_sdk.exceptions import FatalAPIError
Expand Down