1212from contextlib import contextmanager
1313from functools import cached_property
1414from platform import machine
15- from typing import TYPE_CHECKING , Any , BinaryIO
15+ from typing import Any , BinaryIO , TYPE_CHECKING
1616
1717from hatchling .builders .hooks .plugin .interface import BuildHookInterface
1818from hatchling .metadata .plugin .interface import MetadataHookInterface
@@ -34,7 +34,9 @@ def update(self, metadata: dict[str, Any]) -> None:
3434 "Accept" : "application/vnd.github+json" ,
3535 "X-GitHub-Api-Version" : "2022-11-28" ,
3636 }
37- if github_token := (os .environ .get ("GH_TOKEN" ) or os .environ .get ("GITHUB_TOKEN" )):
37+ if github_token := (
38+ os .environ .get ("GH_TOKEN" ) or os .environ .get ("GITHUB_TOKEN" )
39+ ):
3840 headers ["Authorization" ] = f"Bearer { github_token } "
3941
4042 with http_get (
@@ -49,12 +51,16 @@ def update(self, metadata: dict[str, Any]) -> None:
4951
5052
5153class CustomBuildHook (BuildHookInterface ):
52- def initialize (self , version : str , build_data : dict [str , Any ]) -> None : # noqa: ARG002
54+ def initialize (
55+ self , version : str , build_data : dict [str , Any ]
56+ ) -> None : # noqa: ARG002
5357 if self .__source == "release" :
5458 asset = self .__release_asset
5559 elif os .path .isdir (self .__source ):
5660 asset = self .__local_asset
57- elif not os .path .isabs (self .__source ) and os .path .isfile (os .path .join (self .root , "PKG-INFO" )):
61+ elif not os .path .isabs (self .__source ) and os .path .isfile (
62+ os .path .join (self .root , "PKG-INFO" )
63+ ):
5864 msg = (
5965 "The current directory has a `PKG-INFO` file, which likely means that the wheel is being "
6066 "built from an unpacked source distribution. You must do one of the following:\n "
@@ -79,7 +85,9 @@ def initialize(self, version: str, build_data: dict[str, Any]) -> None: # noqa:
7985 build_data ["shared_scripts" ][self .__binary_path ] = self .__binary_name
8086 build_data ["tag" ] = f"py3-none-{ self .__wheel_arch } "
8187
82- def finalize (self , version : str , build_data : dict [str , Any ], artifact : str ) -> None : # noqa: ARG002
88+ def finalize (
89+ self , version : str , build_data : dict [str , Any ], artifact : str
90+ ) -> None : # noqa: ARG002
8391 import shutil
8492
8593 shutil .rmtree (self .__temp_dir )
@@ -121,9 +129,15 @@ def __arch(self) -> str:
121129 def __target_data (self ) -> tuple [str , str ]:
122130 match self .__platform , self .__arch :
123131 case "linux" , "aarch64" :
124- return "dotslash-linux-musl.aarch64.tar.gz" , self .__get_linux_wheel_arch ()
132+ return (
133+ "dotslash-linux-musl.aarch64.tar.gz" ,
134+ self .__get_linux_wheel_arch (),
135+ )
125136 case "linux" , "x86_64" :
126- return "dotslash-linux-musl.x86_64.tar.gz" , self .__get_linux_wheel_arch ()
137+ return (
138+ "dotslash-linux-musl.x86_64.tar.gz" ,
139+ self .__get_linux_wheel_arch (),
140+ )
127141 case "windows" , "arm64" :
128142 return "dotslash-windows-arm64.tar.gz" , "win_arm64"
129143 case "windows" , "amd64" :
@@ -146,7 +160,9 @@ def __wheel_arch(self) -> str:
146160
147161 @cached_property
148162 def __source (self ) -> str :
149- return os .environ .get ("DOTSLASH_SOURCE" ) or self .config .get ("source" ) or "release"
163+ return (
164+ os .environ .get ("DOTSLASH_SOURCE" ) or self .config .get ("source" ) or "release"
165+ )
150166
151167 @cached_property
152168 def __temp_dir (self ) -> str :
0 commit comments