]> 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:

[blackd] Support `py36`-style values in X-Python-Variant header (#979)
authorZsolt Dollenstein <zsol.zsol@gmail.com>
Tue, 13 Aug 2019 15:26:01 +0000 (17:26 +0200)
committerJelle Zijlstra <jelle.zijlstra@gmail.com>
Tue, 13 Aug 2019 15:26:01 +0000 (08:26 -0700)
blackd.py
tests/test_black.py

index 25a9a1589ac9102212fde79aed690a2afad2a153..37fcec31ec10b092a8a273dc03a5d59921d3464c 100644 (file)
--- a/blackd.py
+++ b/blackd.py
@@ -129,7 +129,11 @@ def parse_python_variant_header(value: str) -> Tuple[bool, Set[black.TargetVersi
         for version in value.split(","):
             if version.startswith("py"):
                 version = version[len("py") :]
         for version in value.split(","):
             if version.startswith("py"):
                 version = version[len("py") :]
-            major_str, *rest = version.split(".")
+            if "." in version:
+                major_str, *rest = version.split(".")
+            else:
+                major_str = version[0]
+                rest = [version[1:]] if len(version) > 1 else []
             try:
                 major = int(major_str)
                 if major not in (2, 3):
             try:
                 major = int(major_str)
                 if major not in (2, 3):
index ce8403757f1d699b890dd3c65759fc5b833223ba..3b37011f75f819081c5e7fd02058eab147652f74 100644 (file)
@@ -1624,18 +1624,25 @@ class BlackDTestCase(AioHTTPTestCase):
             response = await self.client.post(
                 "/", data=code, headers={blackd.PYTHON_VARIANT_HEADER: header_value}
             )
             response = await self.client.post(
                 "/", data=code, headers={blackd.PYTHON_VARIANT_HEADER: header_value}
             )
-            self.assertEqual(response.status, expected_status)
+            self.assertEqual(
+                response.status, expected_status, msg=await response.text()
+            )
 
         await check("3.6", 200)
         await check("py3.6", 200)
         await check("3.6,3.7", 200)
         await check("3.6,py3.7", 200)
 
         await check("3.6", 200)
         await check("py3.6", 200)
         await check("3.6,3.7", 200)
         await check("3.6,py3.7", 200)
+        await check("py36,py37", 200)
+        await check("36", 200)
+        await check("3.6.4", 200)
 
         await check("2", 204)
         await check("2.7", 204)
         await check("py2.7", 204)
         await check("3.4", 204)
         await check("py3.4", 204)
 
         await check("2", 204)
         await check("2.7", 204)
         await check("py2.7", 204)
         await check("3.4", 204)
         await check("py3.4", 204)
+        await check("py34,py36", 204)
+        await check("34", 204)
 
     @skip_if_exception("ClientOSError")
     @unittest.skipUnless(has_blackd_deps, "blackd's dependencies are not installed")
 
     @skip_if_exception("ClientOSError")
     @unittest.skipUnless(has_blackd_deps, "blackd's dependencies are not installed")