Skip to content

Commit

Permalink
mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
n8henrie committed Dec 29, 2023
1 parent 3b395ab commit 91401a2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/pycookiecheat/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,9 @@ def chrome_cookies(
{"init_vector": b" " * 16, "length": 16, "salt": b"saltysalt"}
)

if cookie_file is not None:
cookie_file = Path(cookie_file)
else:
if cookie_file is None:
cookie_file = config["cookie_file"]
cookie_file = Path(cookie_file)

if isinstance(password, bytes):
config["my_pass"] = password
Expand Down
10 changes: 7 additions & 3 deletions src/pycookiecheat/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Common code for pycookiecheat."""
from __future__ import annotations

from dataclasses import dataclass
from enum import Enum
from enum import Enum, unique
from typing import Iterator
from warnings import warn

Expand Down Expand Up @@ -61,14 +63,15 @@ def generate_host_keys(hostname: str) -> Iterator[str]:
yield "." + domain


def deprecation_warning(msg: str):
def deprecation_warning(msg: str) -> None:
"""Raise a deprecation warning with the provided message.
`stacklevel=3` tries to show the appropriate calling code to the user.
"""
warn(msg, DeprecationWarning, stacklevel=3)


@unique
class BrowserType(str, Enum):
"""Provide discrete values for recognized browsers.
Expand All @@ -89,8 +92,9 @@ class BrowserType(str, Enum):
FIREFOX = "firefox"
SLACK = "slack"

# https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
@classmethod
def _missing_(cls, value: str):
def _missing_(cls, value: str) -> BrowserType: # type: ignore[override]
"""Provide case-insensitive matching for input values.
>>> BrowserType("chrome")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def ci_setup() -> t.Generator:
ignore_default_args=[
"--use-mock-keychain",
],
executable_path=ex_path, # type: ignore
executable_path=ex_path,
)
page = browser.new_page()
page.goto("https://n8henrie.com")
Expand Down

0 comments on commit 91401a2

Please sign in to comment.