mirror of
https://github.com/jongracecox/anybadge.git
synced 2025-07-21 20:31:03 +02:00
chore: Update pre-commit hooks
Update pre-commit hooks to latest version and apply fixes for mypy type checking and linting.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.3.0
|
||||
rev: v5.0.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
@@ -11,11 +11,11 @@ repos:
|
||||
- id: no-commit-to-branch
|
||||
args: [--branch, master]
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.6.0
|
||||
rev: 24.10.0
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v0.971
|
||||
rev: v1.14.0
|
||||
hooks:
|
||||
- id: mypy
|
||||
additional_dependencies: [types-all]
|
||||
additional_dependencies: [types-requests]
|
||||
|
@@ -107,21 +107,21 @@ class Badge:
|
||||
self,
|
||||
label,
|
||||
value,
|
||||
font_name: str = None,
|
||||
font_size: int = None,
|
||||
num_padding_chars: int = None,
|
||||
num_label_padding_chars: float = None,
|
||||
num_value_padding_chars: float = None,
|
||||
template: Union[Path, str] = None,
|
||||
style: str = None,
|
||||
value_prefix: str = "",
|
||||
value_suffix: str = "",
|
||||
font_name: Optional[str] = None,
|
||||
font_size: Optional[int] = None,
|
||||
num_padding_chars: Optional[int] = None,
|
||||
num_label_padding_chars: Optional[float] = None,
|
||||
num_value_padding_chars: Optional[float] = None,
|
||||
template: Optional[Union[Path, str]] = None,
|
||||
style: Optional[str] = None,
|
||||
value_prefix: Optional[str] = "",
|
||||
value_suffix: Optional[str] = "",
|
||||
thresholds: Optional[Dict[float, str]] = None,
|
||||
default_color: str = None,
|
||||
use_max_when_value_exceeds: bool = True,
|
||||
value_format: str = None,
|
||||
text_color: str = None,
|
||||
semver: bool = False,
|
||||
default_color: Optional[str] = None,
|
||||
use_max_when_value_exceeds: Optional[bool] = True,
|
||||
value_format: Optional[str] = None,
|
||||
text_color: Optional[str] = None,
|
||||
semver: Optional[bool] = False,
|
||||
):
|
||||
"""Constructor for Badge class."""
|
||||
# Set defaults if values were not passed
|
||||
@@ -162,7 +162,18 @@ class Badge:
|
||||
value_text = str(self.value_type(value))
|
||||
self.value_prefix = value_prefix
|
||||
self.value_suffix = value_suffix
|
||||
self.value_text = value_prefix + value_text + value_suffix
|
||||
|
||||
# Combine prefix, value and suffix into a single value_text string
|
||||
|
||||
if value_prefix:
|
||||
self.value_text = value_prefix
|
||||
else:
|
||||
self.value_text = ""
|
||||
|
||||
self.value_text += value_text
|
||||
|
||||
if value_suffix:
|
||||
self.value_text += value_suffix
|
||||
|
||||
if font_name not in config.FONT_WIDTHS:
|
||||
raise ValueError(
|
||||
|
@@ -2,6 +2,7 @@ import argparse
|
||||
import logging
|
||||
from http.server import HTTPServer
|
||||
from os import environ
|
||||
from typing import Optional, Tuple
|
||||
|
||||
from anybadge.server.request_handler import AnyBadgeHTTPRequestHandler
|
||||
from anybadge.server import config
|
||||
@@ -9,7 +10,7 @@ from anybadge.server import config
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run(listen_address: str = None, port: int = None):
|
||||
def run(listen_address: Optional[str] = None, port: Optional[int] = None):
|
||||
"""Run a persistent webserver."""
|
||||
if not listen_address:
|
||||
listen_address = config.DEFAULT_SERVER_LISTEN_ADDRESS
|
||||
@@ -54,12 +55,20 @@ def parse_args() -> argparse.Namespace:
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
"""Run server."""
|
||||
|
||||
# Check for environment variables
|
||||
if "ANYBADGE_PORT" in environ:
|
||||
config.DEFAULT_SERVER_PORT = environ["ANYBADGE_PORT"]
|
||||
port = environ["ANYBADGE_PORT"]
|
||||
try:
|
||||
port_int = int(port)
|
||||
except ValueError:
|
||||
logger.error(
|
||||
"ANYBADGE_PORT environment variable must be an integer. Got %s", port
|
||||
)
|
||||
raise
|
||||
config.DEFAULT_SERVER_PORT = port_int
|
||||
|
||||
if "ANYBADGE_LISTEN_ADDRESS" in environ:
|
||||
config.DEFAULT_SERVER_LISTEN_ADDRESS = environ["ANYBADGE_LISTEN_ADDRESS"]
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Templates package."""
|
||||
|
||||
import pkgutil
|
||||
|
||||
from anybadge.exceptions import UnknownBadgeTemplate
|
||||
|
@@ -4,4 +4,6 @@ pygments
|
||||
pytest
|
||||
pytest-cov
|
||||
requests
|
||||
types-all
|
||||
setuptools
|
||||
types-requests
|
||||
wheel
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Invoke tasks for the project."""
|
||||
|
||||
import glob
|
||||
import os
|
||||
import subprocess
|
||||
|
Reference in New Issue
Block a user