Skip to content

chore: add type-hints to gitlab/config.py #1331

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

Merged
merged 1 commit into from
Feb 25, 2021
Merged
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
11 changes: 7 additions & 4 deletions gitlab/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@

import os
import configparser
from typing import List, Optional, Union

from gitlab.const import USER_AGENT


def _env_config():
def _env_config() -> List[str]:
if "PYTHON_GITLAB_CFG" in os.environ:
return [os.environ["PYTHON_GITLAB_CFG"]]
return []


_DEFAULT_FILES = _env_config() + [
_DEFAULT_FILES: List[str] = _env_config() + [
"/etc/python-gitlab.cfg",
os.path.expanduser("~/.python-gitlab.cfg"),
]
Expand All @@ -50,7 +51,9 @@ class GitlabConfigMissingError(ConfigError):


class GitlabConfigParser(object):
def __init__(self, gitlab_id=None, config_files=None):
def __init__(
self, gitlab_id: Optional[str] = None, config_files: Optional[List[str]] = None
) -> None:
self.gitlab_id = gitlab_id
_files = config_files or _DEFAULT_FILES
file_exist = False
Expand Down Expand Up @@ -85,7 +88,7 @@ def __init__(self, gitlab_id=None, config_files=None):
"configuration (%s)" % self.gitlab_id
) from e

self.ssl_verify = True
self.ssl_verify: Union[bool, str] = True
try:
self.ssl_verify = self._config.getboolean("global", "ssl_verify")
except ValueError:
Expand Down