Skip to content

Commit f696f53

Browse files
committed
Open files using Path.open method
1 parent 63cd453 commit f696f53

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

pydantic_settings/sources/providers/json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(
3838
super().__init__(settings_cls, self.json_data)
3939

4040
def _read_file(self, file_path: Path) -> dict[str, Any]:
41-
with open(file_path, encoding=self.json_file_encoding) as json_file:
41+
with file_path.open(encoding=self.json_file_encoding) as json_file:
4242
return json.load(json_file)
4343

4444
def __repr__(self) -> str:

pydantic_settings/sources/providers/toml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(
5858

5959
def _read_file(self, file_path: Path) -> dict[str, Any]:
6060
import_toml()
61-
with open(file_path, mode='rb') as toml_file:
61+
with file_path.open(mode='rb') as toml_file:
6262
if sys.version_info < (3, 11):
6363
return tomli.load(toml_file)
6464
return tomllib.load(toml_file)

pydantic_settings/sources/providers/yaml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(
6666

6767
def _read_file(self, file_path: Path) -> dict[str, Any]:
6868
import_yaml()
69-
with open(file_path, encoding=self.yaml_file_encoding) as yaml_file:
69+
with file_path.open(encoding=self.yaml_file_encoding) as yaml_file:
7070
return yaml.safe_load(yaml_file) or {}
7171

7272
def __repr__(self) -> str:

0 commit comments

Comments
 (0)