Skip to content

Commit

Permalink
fix: tomllib name error when not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
rubik committed Mar 26, 2023
1 parent 864c461 commit 1be986d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions radon/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
try:
# Python 3.11+
import tomllib
TOMLLIB_PRESENT = True
except ImportError:
try:
# Support for python <3.11
# Support for Python <3.11
import tomli as tomllib
TOMLLIB_PRESENT = True
except ImportError:
pass
TOMLLIB_PRESENT = False

import radon.complexity as cc_mod
from radon.cli.colors import BRIGHT, RED, RESET
Expand Down Expand Up @@ -60,6 +62,9 @@ def get_value(self, key, type, default):

@staticmethod
def toml_config():
if not TOMLLIB_PRESENT:
return {}

try:
with open("pyproject.toml", "rb") as pyproject_file:
pyproject = tomllib.load(pyproject_file)
Expand Down

0 comments on commit 1be986d

Please sign in to comment.