77from pathlib import Path
88
99from cookit .loguru import warning_suppress
10- from cookit .pyd import type_validate_json , type_validate_python
10+ from cookit .pyd import model_fields_set , type_validate_json , type_validate_python
1111from nonebot import logger
1212from nonebot .plugin import Plugin
1313
@@ -26,8 +26,12 @@ def normalize_metadata_user(info: str, allow_multi: bool = False) -> str:
2626
2727@lru_cache
2828def get_dist (module_name : str ) -> Distribution | None :
29- with warning_suppress (f"Unexpected error happened when getting info of package { module_name } " ),\
30- suppress (PackageNotFoundError ): # fmt: skip
29+ with (
30+ warning_suppress (
31+ f"Unexpected error happened when getting info of package { module_name } " ,
32+ ),
33+ suppress (PackageNotFoundError ),
34+ ):
3135 return distribution (module_name )
3236 if "." not in module_name :
3337 return None
@@ -37,8 +41,10 @@ def get_dist(module_name: str) -> Distribution | None:
3741
3842@lru_cache
3943def get_version_attr (module_name : str ) -> str | None :
40- with warning_suppress (f"Unexpected error happened when importing { module_name } " ),\
41- suppress (ImportError ): # fmt: skip
44+ with (
45+ warning_suppress (f"Unexpected error happened when importing { module_name } " ),
46+ suppress (ImportError ),
47+ ):
4248 m = importlib .import_module (module_name )
4349 if ver := getattr (m , "__version__" , None ):
4450 return ver
@@ -93,7 +99,7 @@ async def get_info_from_plugin(plugin: Plugin) -> PMNPluginInfo:
9399 )
94100
95101 pmn = (extra .pmn if extra else None ) or PMNData ()
96- if ("hidden" not in pmn . model_fields_set ) and meta and meta .type == "library" :
102+ if ("hidden" not in model_fields_set ( pmn ) ) and meta and meta .type == "library" :
97103 pmn = PMNData (hidden = True )
98104
99105 logger .debug (f"Completed to get info of plugin { plugin .id_ } " )
0 commit comments