Skip to content

Commit

Permalink
try-except tomllib import
Browse files Browse the repository at this point in the history
See #2965 

I left the version check in place because mypy doesn't generally like try-excepted imports.
  • Loading branch information
JelleZijlstra committed Apr 1, 2022
1 parent def0483 commit 455a7b4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/black/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
from pathspec.patterns.gitwildmatch import GitWildMatchPatternError

if sys.version_info >= (3, 11):
import tomllib
try:
import tomllib
except ImportError:
# Help users on older alphas
import tomli as tomllib
else:
import tomli as tomllib

Expand Down

0 comments on commit 455a7b4

Please sign in to comment.