Skip to content

Commit

Permalink
ci: Use pre-commit.ci (#199)
Browse files Browse the repository at this point in the history
* ci: Use pre-commit.ci

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

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

* Fix files

* Drop black, isort and mypy workflow steps

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
edgarrmondragon and pre-commit-ci[bot] authored May 4, 2023
1 parent 2d7ce36 commit a885286
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 34 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/test_tap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ jobs:
run: |
poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- 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
- name: Test with pytest
id: test_pytest
continue-on-error: true
Expand Down
25 changes: 14 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
ci:
autofix_prs: false
autofix_prs: true
autoupdate_schedule: weekly
autoupdate_commit_msg: 'chore: pre-commit autoupdate'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.4.0
hooks:
- id: check-json
exclude: "\\.vscode/.*.json"
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
rev: v3.3.2
hooks:
- id: pyupgrade
args: [--py36-plus]
args: [--py37-plus]

- repo: https://github.com/psf/black
rev: 22.1.0
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.931
rev: v1.2.0
hooks:
- id: mypy
pass_filenames: true
additional_dependencies:
- types-requests
- types-simplejson
- types-python-dateutil

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
6 changes: 2 additions & 4 deletions tap_github/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,8 @@ def prepare_tokens(self) -> Dict[str, TokenRateLimit]:

if not (github_private_key):
self.logger.warning(
(
"GITHUB_APP_PRIVATE_KEY could not be parsed. The expected format is "
'":app_id:;;-----BEGIN RSA PRIVATE KEY-----\n_YOUR_P_KEY_\n-----END RSA PRIVATE KEY-----"'
)
"GITHUB_APP_PRIVATE_KEY could not be parsed. The expected format is "
'":app_id:;;-----BEGIN RSA PRIVATE KEY-----\n_YOUR_P_KEY_\n-----END RSA PRIVATE KEY-----"'
)

else:
Expand Down
6 changes: 3 additions & 3 deletions tap_github/client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""REST client handling, including GitHubStream base class."""

import collections
import email
import email.utils
import inspect
import random
import re
Expand Down Expand Up @@ -346,7 +346,7 @@ def get_next_page_token(

has_next_page_indices: List[int] = []
# Iterate over all the items and filter items with hasNextPage = True.
for (key, value) in next_page_results.items():
for key, value in next_page_results.items():
# Check if key is even then add pair to new dictionary
if any(value):
pagination_index = int(str(key).split("_")[1])
Expand All @@ -362,7 +362,7 @@ def get_next_page_token(
# We leverage previous_token to remember the pagination cursors
# for indices below max_pagination_index.
next_page_cursors: Dict[str, str] = dict()
for (key, value) in (previous_token or {}).items():
for key, value in (previous_token or {}).items():
# Only keep pagination info for indices below max_pagination_index.
pagination_index = int(str(key).split("_")[1])
if pagination_index < max_pagination_index:
Expand Down
6 changes: 2 additions & 4 deletions tap_github/repository_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,8 @@ def validate_response(self, response: requests.Response) -> None:
# not exist, log some details, and move on to the next one
repo_full_name = "/".join(repo_list[int(item[4:])])
self.logger.info(
(
f"Repository not found: {repo_full_name} \t"
"Removing it from list"
)
f"Repository not found: {repo_full_name} \t"
"Removing it from list"
)
continue
repos_with_ids.append(
Expand Down
7 changes: 3 additions & 4 deletions tap_github/user_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def get_user_ids(self, user_list: List[str]) -> List[Dict[str, str]]:
It also removes non-existant repos and corrects casing to ensure
data is correct downstream.
"""

# use a temp handmade stream to reuse all the graphql setup of the tap
class TempStream(GitHubGraphqlStream):
name = "tempStream"
Expand Down Expand Up @@ -97,10 +98,8 @@ def query(self) -> str:
# not exist, log some details, and move on to the next one
invalid_username = user_list[int(item[4:])]
self.logger.info(
(
f"Username not found: {invalid_username} \t"
"Removing it from list"
)
f"Username not found: {invalid_username} \t"
"Removing it from list"
)
continue
# the databaseId (in graphql language) is not available on
Expand Down
2 changes: 1 addition & 1 deletion tap_github/utils/filter_stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Pattern, TextIO, Union


class FilterStdOutput(object):
class FilterStdOutput:
"""Filter out stdout/sterr given a regex pattern."""

def __init__(self, stream: TextIO, re_pattern: Union[str, Pattern]):
Expand Down

0 comments on commit a885286

Please sign in to comment.