@@ -2961,7 +2961,7 @@ def to(self, filename: PathLike = "", fmt: FileFormats = "", **kwargs) -> str:
2961
2961
json_str = json .dumps (self .as_dict (), ** kwargs )
2962
2962
if filename :
2963
2963
with zopen (filename , mode = "wt" , encoding = "utf-8" ) as file :
2964
- file .write (json_str )
2964
+ file .write (json_str ) # type:ignore[arg-type]
2965
2965
return json_str
2966
2966
2967
2967
elif fmt == "xsf" or fnmatch (filename .lower (), "*.xsf*" ):
@@ -2970,7 +2970,7 @@ def to(self, filename: PathLike = "", fmt: FileFormats = "", **kwargs) -> str:
2970
2970
res_str = XSF (self ).to_str ()
2971
2971
if filename :
2972
2972
with zopen (filename , mode = "wt" , encoding = "utf-8" ) as file :
2973
- file .write (res_str )
2973
+ file .write (res_str ) # type:ignore[arg-type]
2974
2974
return res_str
2975
2975
2976
2976
elif (
@@ -2984,7 +2984,7 @@ def to(self, filename: PathLike = "", fmt: FileFormats = "", **kwargs) -> str:
2984
2984
res_str = Mcsqs (self ).to_str ()
2985
2985
if filename :
2986
2986
with zopen (filename , mode = "wt" , encoding = "ascii" ) as file :
2987
- file .write (res_str )
2987
+ file .write (res_str ) # type:ignore[arg-type]
2988
2988
return res_str
2989
2989
2990
2990
elif fmt == "prismatic" or fnmatch (filename , "*prismatic*" ):
@@ -2999,7 +2999,7 @@ def to(self, filename: PathLike = "", fmt: FileFormats = "", **kwargs) -> str:
2999
2999
yaml_str = str_io .getvalue ()
3000
3000
if filename :
3001
3001
with zopen (filename , mode = "wt" , encoding = "utf-8" ) as file :
3002
- file .write (yaml_str )
3002
+ file .write (yaml_str ) # type:ignore[arg-type]
3003
3003
return yaml_str
3004
3004
3005
3005
elif fmt == "aims" or fnmatch (filename , "geometry.in" ):
@@ -3008,9 +3008,9 @@ def to(self, filename: PathLike = "", fmt: FileFormats = "", **kwargs) -> str:
3008
3008
geom_in = AimsGeometryIn .from_structure (self )
3009
3009
if filename :
3010
3010
with zopen (filename , mode = "wt" , encoding = "utf-8" ) as file :
3011
- file .write (geom_in .get_header (filename ))
3012
- file .write (geom_in .content )
3013
- file .write ("\n " )
3011
+ file .write (geom_in .get_header (filename )) # type:ignore[arg-type]
3012
+ file .write (geom_in .content ) # type:ignore[arg-type]
3013
+ file .write ("\n " ) # type:ignore[arg-type]
3014
3014
return geom_in .content
3015
3015
3016
3016
# fleur support implemented in external namespace pkg https://github.com/JuDFTteam/pymatgen-io-fleur
@@ -3025,7 +3025,7 @@ def to(self, filename: PathLike = "", fmt: FileFormats = "", **kwargs) -> str:
3025
3025
res_str = ResIO .structure_to_str (self )
3026
3026
if filename :
3027
3027
with zopen (filename , mode = "wt" , encoding = "utf-8" ) as file :
3028
- file .write (res_str )
3028
+ file .write (res_str ) # type:ignore[arg-type]
3029
3029
return res_str
3030
3030
3031
3031
elif fmt == "pwmat" or fnmatch (filename .lower (), "*.pwmat" ) or fnmatch (filename .lower (), "*.config" ):
@@ -4013,7 +4013,7 @@ def to(self, filename: str = "", fmt: str = "") -> str | None:
4013
4013
json_str = json .dumps (self .as_dict ())
4014
4014
if filename :
4015
4015
with zopen (filename , mode = "wt" , encoding = "utf-8" ) as file :
4016
- file .write (json_str . encode ( "utf-8" ))
4016
+ file .write (json_str ) # type:ignore[arg-type]
4017
4017
return json_str
4018
4018
elif fmt in {"yaml" , "yml" } or fnmatch (filename , "*.yaml*" ) or fnmatch (filename , "*.yml*" ):
4019
4019
yaml = YAML ()
@@ -4022,7 +4022,7 @@ def to(self, filename: str = "", fmt: str = "") -> str | None:
4022
4022
yaml_str = str_io .getvalue ()
4023
4023
if filename :
4024
4024
with zopen (filename , mode = "wt" , encoding = "utf-8" ) as file :
4025
- file .write (yaml_str . encode ( "utf-8" ))
4025
+ file .write (yaml_str ) # type:ignore[arg-type]
4026
4026
return yaml_str
4027
4027
else :
4028
4028
from pymatgen .io .babel import BabelMolAdaptor
0 commit comments