summaryrefslogtreecommitdiff
path: root/pylint/config/find_default_config_files.py
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2022-04-14 10:50:51 +0200
committerGitHub <noreply@github.com>2022-04-14 10:50:51 +0200
commit99ef057978e2ddd332bdd436fd5fd884deebdc53 (patch)
tree9f835aedf6ad71a06e921207474ed36a3199aec3 /pylint/config/find_default_config_files.py
parent4f7f191f309abde8084f286e11373bbf527db40e (diff)
downloadpylint-git-99ef057978e2ddd332bdd436fd5fd884deebdc53.tar.gz
Use ``python-typing-update`` on ``pylint/config`` directory (#6307)
Diffstat (limited to 'pylint/config/find_default_config_files.py')
-rw-r--r--pylint/config/find_default_config_files.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/pylint/config/find_default_config_files.py b/pylint/config/find_default_config_files.py
index 71ba222b3..34db721ff 100644
--- a/pylint/config/find_default_config_files.py
+++ b/pylint/config/find_default_config_files.py
@@ -2,12 +2,14 @@
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+from __future__ import annotations
+
import configparser
import os
import sys
import warnings
from pathlib import Path
-from typing import Iterator, Optional, Union
+from typing import Iterator
if sys.version_info >= (3, 11):
import tomllib
@@ -18,7 +20,7 @@ RC_NAMES = (Path("pylintrc"), Path(".pylintrc"))
CONFIG_NAMES = RC_NAMES + (Path("pyproject.toml"), Path("setup.cfg"))
-def _toml_has_config(path: Union[Path, str]) -> bool:
+def _toml_has_config(path: Path | str) -> bool:
with open(path, mode="rb") as toml_handle:
try:
content = tomllib.load(toml_handle)
@@ -28,7 +30,7 @@ def _toml_has_config(path: Union[Path, str]) -> bool:
return "pylint" in content.get("tool", [])
-def _cfg_has_config(path: Union[Path, str]) -> bool:
+def _cfg_has_config(path: Path | str) -> bool:
parser = configparser.ConfigParser()
try:
parser.read(path, encoding="utf-8")
@@ -74,7 +76,7 @@ def find_default_config_files() -> Iterator[Path]:
yield Path("/etc/pylintrc").resolve()
-def find_pylintrc() -> Optional[str]:
+def find_pylintrc() -> str | None:
"""Search the pylint rc file and return its path if it finds it, else return None."""
# pylint: disable-next=fixme
# TODO: Remove this function in 3.0