Skip to content

Commit

Permalink
Add type annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
hongquan committed Mar 19, 2022
1 parent 8189413 commit 9c28eef
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 90 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 120
11 changes: 7 additions & 4 deletions chameleon_log/amend.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

import logging
from typing import Dict
from logging import Logger
from typing import Dict, Optional, Callable

import logbook
from logbook import LogRecord
from logbook import LogRecord, Handler
from logbook.compat import LoggingHandler as _LoggingHandler


Expand All @@ -13,8 +14,10 @@ class StdLoggingHandler(_LoggingHandler):
This is to fix the original logbook's LoggingHandler, which tranfers
all message to the root logger, instead of equivalent channels.
'''
def __init__(self, logger=None, level=logbook.NOTSET, filter=None,
bubble=False):
def __init__(self, logger: Optional[Logger] = None,
level: int = logbook.NOTSET,
filter: Optional[Callable[[LogRecord, Handler], bool]] = None,
bubble: bool = False):
super().__init__(logger, level, filter, bubble)
self.sublogs: Dict[str, logging.Handler] = {}

Expand Down
Empty file added chameleon_log/py.typed
Empty file.
144 changes: 60 additions & 84 deletions poetry.lock

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

8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "chameleon-log"
version = "0.1.1"
version = "0.2.0"
description = "Python colored logging setup which adapts to environment"
authors = ["Nguyễn Hồng Quân <[email protected]>"]
readme = "README.rst"
Expand All @@ -14,10 +14,14 @@ classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Operating System :: POSIX :: Linux",
]
packages = [
{include='chameleon_log'},
{include='chameleon_log/py.typed'},
]

[tool.poetry.dependencies]
python = "^3.6"
single-version = "^1.4.1"
single-version = "^1.5.1"
logbook = "^1.5.3"

[tool.poetry.dev-dependencies]
Expand Down

0 comments on commit 9c28eef

Please sign in to comment.