From 47b3154c6acc945cc2cc71ce96f25d2357c6ea47 Mon Sep 17 00:00:00 2001 From: Eriks K Date: Wed, 3 Feb 2021 13:36:26 +0200 Subject: [PATCH] Typehints --- erepublik/citizen.py | 2 +- erepublik/logging.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/erepublik/citizen.py b/erepublik/citizen.py index 310e02c..0ec0565 100644 --- a/erepublik/citizen.py +++ b/erepublik/citizen.py @@ -13,7 +13,7 @@ from requests import HTTPError, RequestException, Response from . import access_points, classes, constants, types, utils from .classes import OfferItem -from .logging import ErepublikLogConsoleHandler, ErepublikFormatter, ErepublikFileHandler, ErepublikErrorHTTTPHandler +from .logging import ErepublikErrorHTTTPHandler, ErepublikFileHandler, ErepublikFormatter, ErepublikLogConsoleHandler class BaseCitizen(access_points.CitizenAPI): diff --git a/erepublik/logging.py b/erepublik/logging.py index 16c7131..d110558 100644 --- a/erepublik/logging.py +++ b/erepublik/logging.py @@ -5,15 +5,15 @@ import logging import os import sys import weakref +from logging import LogRecord, handlers from pathlib import Path +from typing import Any, Dict, Union import requests -from logging import handlers, LogRecord -from typing import Union, Dict, Any from erepublik.classes import Reporter from erepublik.constants import erep_tz -from erepublik.utils import slugify, json_loads, json, now, json_dumps +from erepublik.utils import json, json_dumps, json_loads, slugify class ErepublikFileHandler(handlers.TimedRotatingFileHandler): @@ -85,7 +85,7 @@ class ErepublikErrorHTTTPHandler(handlers.HTTPHandler): def reporter(self): return self._reporter() - def _get_last_response(self): + def _get_last_response(self) -> Dict[str, str]: response = self.reporter.citizen.r url = response.url last_index = url.index("?") if "?" in url else len(response.url) @@ -107,7 +107,7 @@ class ErepublikErrorHTTTPHandler(handlers.HTTPHandler): return dict(name=f"{resp_time}_{name}.{ext}", content=html.encode('utf-8'), mimetype="application/json" if ext == 'json' else "text/html") - def _get_local_vars(self): + def _get_local_vars(self) -> str: trace = inspect.trace() local_vars = {} if trace: @@ -128,7 +128,7 @@ class ErepublikErrorHTTTPHandler(handlers.HTTPHandler): local_vars['citizen'] = repr(local_vars['citizen']) return json_dumps(local_vars) - def _get_instance_json(self): + def _get_instance_json(self) -> str: if self.reporter: return self.reporter.citizen.to_json(False) return ""