Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quiet config #178

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 7 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,14 @@ 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 +72,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
Loading