44import logging
55import os
66from dataclasses import dataclass
7+ from pathlib import Path
78from typing import Optional , Type , TypeVar
89
910import yaml
@@ -110,23 +111,23 @@ def from_env(cls: Type[ProfileSelf], force_none: bool = False) -> ProfileSelf:
110111 return profile
111112
112113 @classmethod
113- def get_default_config_directory (cls ) -> str :
114+ def get_default_config_directory (cls ) -> Path :
114115 xdg_config_path = os .environ .get ("XDG_CONFIG_HOME" )
115116 if xdg_config_path is not None and xdg_config_path != "" :
116- return os . path . join (xdg_config_path , "scw" )
117+ return Path (xdg_config_path ) / "scw"
117118
118- return os . path . join ( os . path . expanduser ("~" ), ".config" , "scw" )
119+ return Path . expanduser ("~" ) / ".config" / "scw"
119120
120121 @classmethod
121- def get_default_config_file_path (cls , filepath : Optional [str ] = None ) -> str :
122+ def get_default_config_file_path (cls , filepath : Optional [str ] = None ) -> Path :
122123 if filepath is not None :
123- return filepath
124+ return Path ( filepath )
124125
125126 filepath = os .environ .get (ENV_KEY_SCW_CONFIG_PATH )
126127 if filepath is not None and filepath != "" :
127- return filepath
128+ return Path ( filepath )
128129
129- return os . path . join ( Profile .get_default_config_directory (), "config.yaml" )
130+ return Profile .get_default_config_directory () / "config.yaml"
130131
131132 @classmethod
132133 def from_config_file (
@@ -137,7 +138,7 @@ def from_config_file(
137138 ) -> ProfileSelf :
138139 filepath = cls .get_default_config_file_path (filepath )
139140
140- with open (filepath , "r" ) as f :
141+ with Path (filepath ). open ( "r" ) as f :
141142 config = yaml .safe_load (f )
142143
143144 if not isinstance (config , dict ):
0 commit comments