Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ jobs:
python-version: "3.10"
architecture: x64
- name: Install dependencies
run: python -m pip install -U pip black pyupgrade
run: python -m pip install -U pip black pyupgrade isort
- name: Check Python Formatting
run: black --check .
- name: Check Python import sorting
run: isort --check .
- name: Check pyupgrade
run: pyupgrade --py37-plus src/picologging/*.py tests/**/*.py
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ repos:
rev: v3.1.0
hooks:
- id: pyupgrade
args: ['--py37-plus']
args: ['--py37-plus']
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
9 changes: 5 additions & 4 deletions benchmarks/bench_handlers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import tempfile
import io
import logging
import picologging
import logging.handlers as logging_handlers
import picologging.handlers as picologging_handlers
import queue
import io
import tempfile

import picologging
import picologging.handlers as picologging_handlers


def filehandler_logging():
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/bench_logger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from io import StringIO
import logging
from io import StringIO

import picologging

logging.basicConfig()
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ test-command = "python -X dev -m pytest {project}/tests"
environment = { MACOSX_DEPLOYMENT_TARGET = "10.15" }

[tool.pylint.messages_control]
disable = "C0114,C0115,C0116"
disable = "C0114,C0115,C0116"

[tool.isort]
profile = "black"
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from skbuild import setup
from setuptools import find_packages

from skbuild import setup

with open("./README.md") as fh:
long_description = fh.read()
Expand Down
3 changes: 2 additions & 1 deletion slowtests/test_logrecordhyp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import sys

import pytest
from hypothesis import given, reproduce_failure, strategies as st
from flaky import flaky
from hypothesis import given, reproduce_failure
from hypothesis import strategies as st

import picologging

Expand Down
20 changes: 8 additions & 12 deletions src/picologging/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import sys
import io
import os
import sys
import warnings
from logging import BufferingFormatter, Filter, StringTemplateStyle, _checkLevel

from ._picologging import Handler # NOQA
from ._picologging import (
LogRecord,
Filterer,
FormatStyle,
Formatter,
Logger,
Filterer,
Handler,
LogRecord,
StreamHandler,
getLevelName,
) # NOQA
from logging import (
_checkLevel,
Filter,
StringTemplateStyle,
BufferingFormatter,
)
import io
import warnings

__version__ = "0.8.1"

Expand Down
5 changes: 3 additions & 2 deletions src/picologging/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from _typeshed import StrPath, SupportsWrite
from collections.abc import Callable, Iterable, Mapping
from io import TextIOWrapper
from multiprocessing import Manager
from string import Template
from types import TracebackType
from typing import Any, Generic, Pattern, TextIO, TypeVar, Union, overload, Optional
from typing import Any, Generic, Optional, Pattern, TextIO, TypeVar, Union, overload

from _typeshed import StrPath, SupportsWrite
from typing_extensions import Literal, TypeAlias

CRITICAL: int
Expand Down
5 changes: 3 additions & 2 deletions src/picologging/handlers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import queue
import os
import pickle
import queue
import re
import socket
import struct
import time
import threading
import time

import picologging

_MIDNIGHT = 24 * 60 * 60 # number of seconds in a day
Expand Down
7 changes: 4 additions & 3 deletions src/picologging/handlers.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from datetime import datetime
from typing import Any, Callable, Pattern
from _typeshed import StrPath
from queue import Queue, SimpleQueue
from socket import socket
from typing import Any, Callable, Pattern

from _typeshed import StrPath

from picologging import Handler, FileHandler, LogRecord
from picologging import FileHandler, Handler, LogRecord

class WatchedFileHandler(FileHandler):
baseFilename: str # undocumented
Expand Down
6 changes: 4 additions & 2 deletions tests/fuzzing/fuzz_atheris.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import atheris
import io

import atheris

with atheris.instrument_imports():
import picologging
import sys

import picologging

picologging.basicConfig()
logger = picologging.Logger("fuzz", picologging.DEBUG)
tmp = io.StringIO()
Expand Down
3 changes: 2 additions & 1 deletion tests/memray/memray_format_exception.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from picologging import Formatter
import sys

from picologging import Formatter


def test_format_exception():
pico_f = Formatter("%(message)s")
Expand Down
3 changes: 2 additions & 1 deletion tests/memray/memray_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
Create 100,000 logger instances and run a log test on them
"""

import picologging
from io import StringIO

import picologging


def log(level=picologging.INFO):
logger = picologging.Logger("test", level)
Expand Down
3 changes: 2 additions & 1 deletion tests/memray/memray_logrecord.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import picologging
from io import StringIO

import picologging


def log(level=picologging.INFO):
logger = picologging.Logger("test", level)
Expand Down
3 changes: 2 additions & 1 deletion tests/profile/profile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import picologging
from io import StringIO

import picologging


def run_profile(level=picologging.DEBUG):
logger = picologging.Logger("test", level)
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

import picologging
from picologging.config import dictConfig, valid_ident

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_filehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import picologging
from picologging.handlers import (
WatchedFileHandler,
RotatingFileHandler,
TimedRotatingFileHandler,
WatchedFileHandler,
)


Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_formatter.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from picologging import Formatter, LogRecord
import datetime
import logging
import sys

import pytest
import datetime

from picologging import Formatter, LogRecord


def test_formatter_default_fmt():
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_handler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import picologging
import pytest

import picologging


def test_basic_handler():
handler = picologging.Handler()
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_logger.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import io
import uuid
import picologging
import logging
import uuid

import pytest

import picologging


def test_logger_attributes():
logger = picologging.Logger("test")
Expand Down
10 changes: 6 additions & 4 deletions tests/unit/test_logrecord.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import threading
from picologging import LogRecord
import picologging
import logging
import pytest
import os
import threading

import pytest

import picologging
from picologging import LogRecord


def test_logrecord_standard():
Expand Down
8 changes: 5 additions & 3 deletions tests/unit/test_percentstyle.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from picologging import PercentStyle, LogRecord, INFO
import pytest
import threading
import logging
import threading

import pytest

from picologging import INFO, LogRecord, PercentStyle


def test_percentstyle():
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_picologging.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import sys
import picologging
import logging
import sys

import pytest

import picologging

levels = [
(picologging.DEBUG, "DEBUG"),
(picologging.INFO, "INFO"),
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/test_queuehandler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from picologging.handlers import QueueHandler, QueueListener
import picologging
import queue
import io
import queue

import picologging
from picologging.handlers import QueueHandler, QueueListener


def test_queue_handler_dispatch():
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_sockethandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import threading
from socketserver import (
DatagramRequestHandler,
ThreadingTCPServer,
StreamRequestHandler,
ThreadingTCPServer,
ThreadingUDPServer,
)

Expand Down
4 changes: 3 additions & 1 deletion tests/unit/test_streamhandler.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import io
import sys
import picologging

import pytest

import picologging


def test_stream_handler():
stream = io.StringIO()
Expand Down
8 changes: 5 additions & 3 deletions tests/unit/test_strformatstyle.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from picologging import Formatter, StrFormatStyle, LogRecord, INFO
import pytest
import threading
import logging
import threading

import pytest

from picologging import INFO, Formatter, LogRecord, StrFormatStyle


def test_strformatstyle():
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_threading.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import io
import threading

import picologging
from picologging import Logger, StreamHandler
import io


def test_threaded_execution():
Expand Down