@@ -26,15 +26,13 @@ def __init__(self, *, data: bytes | str, path: Path) -> None:
2626 self ._parse_setting (data )
2727
2828 def contains_commitizen_section (self ) -> bool :
29- with self .path .open ("rb" ) as f :
30- config_doc = parse (f .read ())
29+ config_doc = parse (self .path .read_bytes ())
3130 return config_doc .get ("tool" , {}).get ("commitizen" ) is not None
3231
3332 def init_empty_config_content (self ) -> None :
3433 config_doc = TOMLDocument ()
3534 if self .path .is_file ():
36- with self .path .open ("rb" ) as input_toml_file :
37- config_doc = parse (input_toml_file .read ())
35+ config_doc = parse (self .path .read_bytes ())
3836
3937 if config_doc .get ("tool" ) is None :
4038 config_doc ["tool" ] = table ()
@@ -46,12 +44,10 @@ def init_empty_config_content(self) -> None:
4644 )
4745
4846 def set_key (self , key : str , value : object ) -> Self :
49- with self .path .open ("rb" ) as f :
50- config_doc = parse (f .read ())
47+ config_doc = parse (self .path .read_bytes ())
5148
5249 config_doc ["tool" ]["commitizen" ][key ] = value # type: ignore[index]
53- with self .path .open ("wb" ) as f :
54- f .write (config_doc .as_string ().encode (self ._settings ["encoding" ]))
50+ self .path .write_bytes (config_doc .as_string ().encode (self ._settings ["encoding" ]))
5551
5652 return self
5753
0 commit comments