Skip to content

Commit f7e5b20

Browse files
authored
Merge pull request #1 from esbmc/config-type-paths
refactor: better types for path args
2 parents 0f1adfe + 2e0e824 commit f7e5b20

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

compile_flags/config.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
# SPDX-License-Identifier: AGPL-3.0
44

55
import logging
6+
import os
7+
from pathlib import Path
68
import sys
79

810
import structlog
9-
from pydantic import AliasChoices, Field, PrivateAttr, computed_field
11+
from pydantic import AliasChoices, DirectoryPath, Field, FilePath, PrivateAttr, computed_field
1012
from pydantic_settings import BaseSettings, SettingsConfigDict
1113

1214

@@ -67,7 +69,7 @@ class Config(BaseSettings):
6769
cli_parse_args=True,
6870
)
6971

70-
output_file: str | None = Field(
72+
output_file: FilePath | None = Field(
7173
default=None,
7274
validation_alias=_alias_choice("output_file"),
7375
description="Output file path for compilation flags",
@@ -76,11 +78,12 @@ class Config(BaseSettings):
7678
language: str | None = Field(
7779
default=None,
7880
validation_alias=_alias_choice("language"),
79-
description="Programming language to detect flags for (e.g., c, cpp, rust)",
81+
description="Programming language to detect flags for "
82+
"(e.g., c, cpp, rust). Will try and automatically detect if unspecified",
8083
)
8184

82-
build_dir: str = Field(
83-
default=".",
85+
build_dir: DirectoryPath = Field(
86+
default=Path(os.getcwd()),
8487
validation_alias=_alias_choice("build_dir"),
8588
description="Build directory to analyze",
8689
)
@@ -96,3 +99,4 @@ def log_level(self) -> int:
9699
def log_level_name(self) -> str:
97100
"""The current log level name."""
98101
return logging.getLevelName(self.log_level)
102+

0 commit comments

Comments
 (0)