11"""Configuration parser for YAML and JSON files."""
22
3+ from __future__ import annotations
4+
35import json
46import pathlib
57import typing as t
@@ -24,11 +26,11 @@ class ConfigReader:
2426 '{\n "session_name": "my session"\n}'
2527 """
2628
27- def __init__ (self , content : " RawConfigData" ) -> None :
29+ def __init__ (self , content : RawConfigData ) -> None :
2830 self .content = content
2931
3032 @staticmethod
31- def _load (fmt : " FormatLiteral" , content : str ) -> dict [str , t .Any ]:
33+ def _load (fmt : FormatLiteral , content : str ) -> dict [str , t .Any ]:
3234 """Load raw config data and directly return it.
3335
3436 >>> ConfigReader._load("json", '{ "session_name": "my session" }')
@@ -51,7 +53,7 @@ def _load(fmt: "FormatLiteral", content: str) -> dict[str, t.Any]:
5153 raise NotImplementedError (msg )
5254
5355 @classmethod
54- def load (cls , fmt : " FormatLiteral" , content : str ) -> " ConfigReader" :
56+ def load (cls , fmt : FormatLiteral , content : str ) -> ConfigReader :
5557 """Load raw config data into a ConfigReader instance (to dump later).
5658
5759 >>> cfg = ConfigReader.load("json", '{ "session_name": "my session" }')
@@ -120,7 +122,7 @@ def _from_file(cls, path: pathlib.Path) -> dict[str, t.Any]:
120122 )
121123
122124 @classmethod
123- def from_file (cls , path : pathlib .Path ) -> " ConfigReader" :
125+ def from_file (cls , path : pathlib .Path ) -> ConfigReader :
124126 r"""Load data from file path.
125127
126128 **YAML file**
@@ -161,8 +163,8 @@ def from_file(cls, path: pathlib.Path) -> "ConfigReader":
161163
162164 @staticmethod
163165 def _dump (
164- fmt : " FormatLiteral" ,
165- content : " RawConfigData" ,
166+ fmt : FormatLiteral ,
167+ content : RawConfigData ,
166168 indent : int = 2 ,
167169 ** kwargs : t .Any ,
168170 ) -> str :
@@ -189,7 +191,7 @@ def _dump(
189191 msg = f"{ fmt } not supported in config"
190192 raise NotImplementedError (msg )
191193
192- def dump (self , fmt : " FormatLiteral" , indent : int = 2 , ** kwargs : t .Any ) -> str :
194+ def dump (self , fmt : FormatLiteral , indent : int = 2 , ** kwargs : t .Any ) -> str :
193195 r"""Dump via ConfigReader instance.
194196
195197 >>> cfg = ConfigReader({ "session_name": "my session" })
0 commit comments