try-except tomllib import (#2987)
See #2965 I left the version check in place because mypy doesn't generally like try-excepted imports.
This commit is contained in:
parent
5436810921
commit
1af29fbfa5
@ -39,6 +39,9 @@
|
||||
|
||||
<!-- Changes to how Black is packaged, such as dependency requirements -->
|
||||
|
||||
- Use `tomli` instead of `tomllib` on Python 3.11 builds where `tomllib` is not
|
||||
available (#2987)
|
||||
|
||||
### Parser
|
||||
|
||||
<!-- Changes to the parser or to version autodetection -->
|
||||
|
2
setup.py
2
setup.py
@ -98,7 +98,7 @@ def find_python_files(base: Path) -> List[Path]:
|
||||
install_requires=[
|
||||
"click>=8.0.0",
|
||||
"platformdirs>=2",
|
||||
"tomli>=1.1.0; python_version < '3.11'",
|
||||
"tomli>=1.1.0; python_full_version < '3.11.0a7'",
|
||||
"typed-ast>=1.4.2; python_version < '3.8' and implementation_name == 'cpython'",
|
||||
"pathspec>=0.9.0",
|
||||
"dataclasses>=0.6; python_version < '3.7'",
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user