Skip to content

Commit

Permalink
Hide msg about loading config in quiet mode (#178)
Browse files Browse the repository at this point in the history
Co-authored-by: jsh9 <[email protected]>
  • Loading branch information
aemonge and jsh9 authored Dec 1, 2024
1 parent 8170436 commit d9da0fa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [Unpublished]

- Changed
- Command line message about loading config file is now hidden with config
option `--quiet`

## [0.5.9] - 2024-09-29

- Fixed
Expand Down
2 changes: 2 additions & 0 deletions pydoclint/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ast
import logging
import re
from pathlib import Path
from typing import Dict, List, Optional, Tuple
Expand Down Expand Up @@ -329,6 +330,7 @@ def main( # noqa: C901
config: Optional[str], # don't remove it b/c it's required by `click`
) -> None:
"""Command-line entry point of pydoclint"""
logging.basicConfig(level=logging.WARN if quiet else logging.INFO)
ctx.ensure_object(dict)

if type_hints_in_docstring != 'None': # it means users supply this option
Expand Down
15 changes: 9 additions & 6 deletions pydoclint/parse_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import sys
from pathlib import Path
from typing import Any, Dict, Optional, Sequence
Expand Down Expand Up @@ -36,7 +37,7 @@ def injectDefaultOptionsFromUserSpecifiedTomlFilePath(
if not value:
return None

print(f'Loading config from user-specified .toml file: {value}')
logging.info(f'Loading config from user-specified .toml file: {value}')
config = parseOneTomlFile(tomlFilename=Path(value))
updateCtxDefaultMap(ctx=ctx, config=config)
return value
Expand All @@ -49,14 +50,16 @@ def parseToml(paths: Optional[Sequence[str]]) -> Dict[str, Any]:

commonParent: Path = findCommonParentFolder(paths)
tomlFilename = commonParent / Path('pyproject.toml')
print(f'Loading config from inferred .toml file path: {tomlFilename}')
logging.info(
f'Loading config from inferred .toml file path: {tomlFilename}'
)
return parseOneTomlFile(tomlFilename)


def parseOneTomlFile(tomlFilename: Path) -> Dict[str, Any]:
"""Parse a .toml file"""
if not tomlFilename.exists():
print(f'File "{tomlFilename}" does not exist; nothing to load.')
logging.info(f'File "{tomlFilename}" does not exist; nothing to load.')
return {}

try:
Expand All @@ -71,10 +74,10 @@ def parseOneTomlFile(tomlFilename: Path) -> Dict[str, Any]:
finalConfig = {}

if len(finalConfig) > 0:
print(f'Found options defined in {tomlFilename}:')
print(finalConfig)
logging.info(f'Found options defined in {tomlFilename}:')
logging.info(finalConfig)
else:
print(f'No config found in {tomlFilename}.')
logging.info(f'No config found in {tomlFilename}.')

return finalConfig

Expand Down

0 comments on commit d9da0fa

Please sign in to comment.