From 00d7cc0cfa2fc6ba5fdd5d74769be45841a1d1cb Mon Sep 17 00:00:00 2001 From: Alexandre Teles Date: Mon, 10 Apr 2023 21:50:20 -0300 Subject: [PATCH] feat: dependabot, mypy and security --- .github/dependabot.yml | 16 ++++++++++++++++ SECURITY.md | 11 +++++++++++ mypy.ini | 16 ++++++++++++++++ src/app/api.py | 2 +- src/app/generator.py | 12 +++++++----- src/app/utils.py | 8 ++++---- 6 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 SECURITY.md create mode 100644 mypy.ini diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..cad22b2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + assignees: + - "alexandreteles" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + assignees: + - "alexandreteles" diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..a96b0b4 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,11 @@ +# Security Policy + +## Supported Tags + +| Tag | ReVanced Version | +| ------- | ------------------ | +| latest | latest upstream | + +## Reporting a Vulnerability + +To report a vulnerability, please open an Issue in our issue tracker here on GitHub. diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..f539685 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,16 @@ +[mypy] +python_version = 3.11 +pretty = true +follow_imports = normal +namespace_packages = true +show_column_numbers = true +show_error_codes = true +allow_redefinition = false +implicit_reexport = false +strict_optional = true +strict_equality = true +warn_no_return = true +warn_redundant_casts = true +warn_unused_configs = true +warn_unused_ignores = true +warn_unreachable = true diff --git a/src/app/api.py b/src/app/api.py index f37bacd..e02e55d 100644 --- a/src/app/api.py +++ b/src/app/api.py @@ -58,7 +58,7 @@ class GitHubApi(Api): } def sort_and_delete_key(contributor: dict) -> int: - contributions = contributor["contributions"] + contributions: int = contributor["contributions"] del contributor["contributions"] return contributions diff --git a/src/app/generator.py b/src/app/generator.py index 44aec0b..718c9bf 100644 --- a/src/app/generator.py +++ b/src/app/generator.py @@ -8,7 +8,7 @@ from abc import abstractmethod class Api: _api: api.Api - def __init__(self, name: str, api: api.Api = api.GitHubApi()): + def __init__(self, name: str, api: api.Api = api.GitHubApi()) -> None: self.name = name self._api = api @@ -25,8 +25,9 @@ class Api: class ReleaseApi(Api): - def __init__(self, api): + def __init__(self, api) -> None: super().__init__("release", api) + pass def generate(self, config, path): path = join(path, "release") @@ -60,8 +61,9 @@ class ReleaseApi(Api): class ContributorApi(Api): - def __init__(self, api): + def __init__(self, api) -> None: super().__init__("contributor", api) + pass def generate(self, config, path): path = join(path, "contributor") @@ -79,7 +81,7 @@ class ContributorApi(Api): class SocialApi(Api): - def __init__(self, api): + def __init__(self, api) -> None: super().__init__("social", api) def generate(self, config, path): @@ -94,7 +96,7 @@ class SocialApi(Api): class ApiProvider: _apis: list[Api] - def __init__(self, apis: list[Api]): + def __init__(self, apis: list[Api]) -> None: self._apis = apis def get(self, name: str) -> Api | None: diff --git a/src/app/utils.py b/src/app/utils.py index 91f0e85..23bcc51 100644 --- a/src/app/utils.py +++ b/src/app/utils.py @@ -2,7 +2,7 @@ import json import os -def write_json(text: str | dict | list, to, overwrite=True): +def write_json(text: str | dict | list, to: str, overwrite: bool = True): if not os.path.exists(to) or overwrite: with open(to, "w") as f: if not isinstance(text, str): @@ -10,16 +10,16 @@ def write_json(text: str | dict | list, to, overwrite=True): f.write(text) -def read_json(path, default): +def read_json(path: str, default: list) -> list: if os.path.exists(path): with open(path, "r") as f: return json.load(f) return default -def create_if_not_exists(path): +def create_if_not_exists(path: str): os.makedirs(path, exist_ok=True) -def get_repository_name(repository: str): +def get_repository_name(repository: str) -> str: return repository.split("/")[-1]