Update pre-commit and get tests passing

This commit is contained in:
IamTheFij 2022-01-05 20:25:58 -08:00
parent 764d0f9e3a
commit c2ae14d48c
7 changed files with 31 additions and 34 deletions

View File

@ -8,10 +8,6 @@ PYTHON_VERSIONS = [
"latest", "latest",
] ]
PYPY3_VERSIONS = [
"3",
]
def main(ctx): def main(ctx):
pipelines = [] pipelines = []
@ -48,9 +44,6 @@ def tests():
"steps": [ "steps": [
tox_step("python:"+version) tox_step("python:"+version)
for version in PYTHON_VERSIONS for version in PYTHON_VERSIONS
] + [
tox_step("pypy:"+version, "pypy3", "pypy3")
for version in PYPY3_VERSIONS
], ],
}] }]
@ -121,7 +114,7 @@ def push_to_pypi():
"trigger": { "trigger": {
"event": ["tag"], "event": ["tag"],
"ref": [ "ref": [
"refs/heads/master", "refs/heads/main",
"refs/tags/v*", "refs/tags/v*",
], ],
}, },

View File

@ -1,13 +1,11 @@
--- ---
default_language_version:
python: python3.8
repos: repos:
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 20.8b1 rev: 21.12b0
hooks: hooks:
- id: black - id: black
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0 rev: v4.1.0
hooks: hooks:
- id: check-added-large-files - id: check-added-large-files
- id: check-merge-conflict - id: check-merge-conflict
@ -17,10 +15,12 @@ repos:
- id: name-tests-test - id: name-tests-test
exclude: tests/(common.py|util.py|(helpers|integration/factories)/(.+).py) exclude: tests/(common.py|util.py|(helpers|integration/factories)/(.+).py)
- repo: https://github.com/asottile/reorder_python_imports - repo: https://github.com/asottile/reorder_python_imports
rev: v2.4.0 rev: v2.6.0
hooks: hooks:
- id: reorder-python-imports - id: reorder-python-imports
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.800 rev: v0.930
hooks: hooks:
- id: mypy - id: mypy
exclude: docs/
additional_dependencies: [ "types-requests" ]

View File

@ -1,6 +1,6 @@
OPEN_CMD := $(shell type xdg-open &> /dev/null && echo 'xdg-open' || echo 'open') OPEN_CMD := $(shell type xdg-open &> /dev/null && echo 'xdg-open' || echo 'open')
NAME := release-gitter NAME := release-gitter
ENV := env ENV := venv
.PHONY: default .PHONY: default
default: test default: test

View File

@ -3,9 +3,7 @@
# This file only contains a selection of the most common options. For a full # This file only contains a selection of the most common options. For a full
# list see the documentation: # list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html # https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup -------------------------------------------------------------- # -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
@ -13,13 +11,11 @@
# import os # import os
# import sys # import sys
# sys.path.insert(0, os.path.abspath('.')) # sys.path.insert(0, os.path.abspath('.'))
# -- Project information ----------------------------------------------------- # -- Project information -----------------------------------------------------
project = 'release-gitter' project = "release-gitter"
copyright = '2021, iamthefij' copyright = "2021, iamthefij"
author = 'iamthefij' author = "iamthefij"
# -- General configuration --------------------------------------------------- # -- General configuration ---------------------------------------------------
@ -27,11 +23,10 @@ author = 'iamthefij'
# Add any Sphinx extension module names here, as strings. They can be # Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones. # ones.
extensions = [ extensions = []
]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates'] templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
@ -44,9 +39,9 @@ exclude_patterns = []
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
# #
html_theme = 'alabaster' html_theme = "alabaster"
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static'] html_static_path = ["_static"]

View File

@ -21,6 +21,7 @@ import requests
# Extract metadata from repo # Extract metadata from repo
class InvalidRemoteError(ValueError): class InvalidRemoteError(ValueError):
pass pass
@ -36,7 +37,9 @@ class GitRemoteInfo:
Currently only supporting Github and Gitea APIs""" Currently only supporting Github and Gitea APIs"""
if self.hostname == "github.com": if self.hostname == "github.com":
return f"https://api.{self.hostname}/repos/{self.owner}/{self.repo}/releases" return (
f"https://api.{self.hostname}/repos/{self.owner}/{self.repo}/releases"
)
# Try to detect an api # Try to detect an api
swagger_uri = f"https://{self.hostname}/swagger.v1.json" swagger_uri = f"https://{self.hostname}/swagger.v1.json"
@ -73,7 +76,9 @@ def get_git_remote(git_url: Optional[str] = None) -> GitRemoteInfo:
if git_url.startswith("git@github.com:"): if git_url.startswith("git@github.com:"):
git_ssh_parts = git_url.partition(":") git_ssh_parts = git_url.partition(":")
if not all(git_ssh_parts): if not all(git_ssh_parts):
raise InvalidRemoteError(f"Could not parse URL {git_url}. Is this an ssh url?") raise InvalidRemoteError(
f"Could not parse URL {git_url}. Is this an ssh url?"
)
git_url = f"ssh://{git_ssh_parts[0]}/{git_ssh_parts[2]}" git_url = f"ssh://{git_ssh_parts[0]}/{git_ssh_parts[2]}"
u = urlparse(git_url) u = urlparse(git_url)
@ -82,7 +87,9 @@ def get_git_remote(git_url: Optional[str] = None) -> GitRemoteInfo:
path = u.path.split("/") path = u.path.split("/")
if len(path) < 3 or not all(path[1:3]): if len(path) < 3 or not all(path[1:3]):
raise InvalidRemoteError(f"{path[1:3]} Could not parse owner and repo from URL {git_url}") raise InvalidRemoteError(
f"{path[1:3]} Could not parse owner and repo from URL {git_url}"
)
return GitRemoteInfo(u.hostname, path[1], path[2].removesuffix(".git")) return GitRemoteInfo(u.hostname, path[1], path[2].removesuffix(".git"))

View File

@ -17,7 +17,9 @@ setup(
long_description=long_description, long_description=long_description,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
url="https://git.iamthefij.com/iamthefij/release-gitter.git", url="https://git.iamthefij.com/iamthefij/release-gitter.git",
download_url=("https://git.iamthefij.com/iamthefij/release-gitter.git/archive/master.tar.gz"), download_url=(
"https://git.iamthefij.com/iamthefij/release-gitter.git/archive/master.tar.gz"
),
author="iamthefij", author="iamthefij",
author_email="", author_email="",
classifiers=[ classifiers=[

View File

@ -1,13 +1,13 @@
[tox] [tox]
envlist = py3,pypy3 envlist = py3
[testenv] [testenv]
deps = deps =
-rrequirements-dev.txt -rrequirements-dev.txt
commands = commands =
coverage erase coverage erase
coverage run --source=release_gitter/ -m pytest --capture=no -vv {posargs:tests} coverage run --source=release_gitter -m unittest discover . {posargs:"*_test.py"}
coverage report -m --fail-under 70 # coverage report -m --fail-under 70
pre-commit run --all-files pre-commit run --all-files
[testenv:pre-commit] [testenv:pre-commit]