Skip to content

Commit

Permalink
Use Literal for __title__ and logger_name
Browse files Browse the repository at this point in the history
  • Loading branch information
realshouzy committed Jun 10, 2024
1 parent c83325a commit 04f8009
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pip_manage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
from __future__ import annotations

__version__: Final[str] = "1.0.3"
__title__: Final[str] = "pip-manage"
__title__: Literal["pip-manage"] = "pip-manage"

from typing import Final
from typing import Final, Literal
6 changes: 5 additions & 1 deletion pip_manage/_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ def format(self, record: logging.LogRecord) -> str:
return super().format(record)


def setup_logging(logger_name: str, *, verbose: bool) -> None:
def setup_logging(
logger_name: Literal["pip-review", "pip-purge"],
*,
verbose: bool,
) -> None:
level: Literal["DEBUG", "INFO"] = "DEBUG" if verbose else "INFO"
logging.config.dictConfig(
{
Expand Down
4 changes: 2 additions & 2 deletions pip_manage/pip_purge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"""pip-purge lets you smoothly uninstall packages and their dependencies."""
from __future__ import annotations

__title__: Final[str] = "pip-purge"
__title__: Literal["pip-purge"] = "pip-purge"

import argparse
import importlib.metadata
import logging
from pathlib import Path
from typing import TYPE_CHECKING, Final, NamedTuple
from typing import TYPE_CHECKING, Final, Literal, NamedTuple

from pip_manage._logging import setup_logging
from pip_manage._pip_interface import (
Expand Down
4 changes: 2 additions & 2 deletions pip_manage/pip_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"""pip-review lets you smoothly manage all available PyPI updates."""
from __future__ import annotations

__title__: Final[str] = "pip-review"
__title__: Literal["pip-review"] = "pip-review"

import argparse
import logging
import os
from pathlib import Path
from typing import TYPE_CHECKING, Final, NamedTuple
from typing import TYPE_CHECKING, Final, Literal, NamedTuple

from pip_manage._logging import setup_logging
from pip_manage._pip_interface import (
Expand Down

0 comments on commit 04f8009

Please sign in to comment.