Skip to content

Commit

Permalink
be explict about versions for later cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Dec 17, 2024
1 parent 479ae4f commit e4bbaf5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions jupyter_events/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
import typing as t
import warnings
from datetime import datetime, timezone
from importlib.metadata import version

from jsonschema import ValidationError
from packaging.version import parse

try:
from pythonjsonlogger.json import JsonFormatter
except ImportError:
from pythonjsonlogger.jsonlogger import JsonFormatter
# Check if the version is greater than 3.0.0
from traitlets import Dict, Instance, Set, default
from traitlets.config import Config, LoggingConfigurable

Expand All @@ -25,6 +24,12 @@
from .traits import Handlers
from .validators import JUPYTER_EVENTS_CORE_VALIDATOR

version_info = version("pythonjsonlogger")
if parse(version_info) >= parse("3.1.0"):
from pythonjsonlogger.json import JsonFormatter
else:
from pythonjsonlogger.jsonlogger import JsonFormatter

# Increment this version when the metadata included with each event
# changes.
EVENTS_METADATA_VERSION = 1
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ extend-select = [
"EXE", # flake8-executable
"PYI", # flake8-pyi
"S", # flake8-bandit
"G001", # .format and co in logging methods
]
ignore = [
"E501", # E501 Line too long (158 > 100 characters)
Expand Down

0 comments on commit e4bbaf5

Please sign in to comment.