]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

try-except tomllib import (#2987)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Sat, 2 Apr 2022 15:29:32 +0000 (08:29 -0700)
committerGitHub <noreply@github.com>
Sat, 2 Apr 2022 15:29:32 +0000 (08:29 -0700)
See #2965

I left the version check in place because mypy doesn't generally like try-excepted imports.

CHANGES.md
setup.py
src/black/files.py

index f68bc8f1a9946dcffa93ba90c6499674e50a3216..f2bdbd2e2b7be62a94138ecaa5bd9feff8df2e64 100644 (file)
@@ -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 -->
index e23a58c411c4806e67d5cb5fa83a35c0d4a59b30..522a42a7ce216a3ba0cd723b91781cbc6f5526b2 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -98,7 +98,7 @@ setup(
     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'",
index 52c77c63346ce36eddb6417cdab8061994567cbb..0382397e8a230f60f6a0b4cec6ee07bc80f9e281 100644 (file)
@@ -22,7 +22,11 @@ from pathspec import PathSpec
 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