Skip to content

Commit

Permalink
fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Dec 9, 2023
1 parent 5ef2fa1 commit 0a3f114
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/mxdev/including.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

def resolve_dependencies(
file_or_url: typing.Union[str, pathlib.Path],
tmpdir: tempfile.TemporaryDirectory,
tmpdir: str,
http_parent=None,
) -> list[pathlib.Path]:
"""Resolve dependencies of a file or url
Expand All @@ -25,10 +25,10 @@ def resolve_dependencies(
if isinstance(file_or_url, str):
if http_parent:
file_or_url = parse.urljoin(http_parent, file_or_url)
parsed = parse.urlparse(file_or_url)
parsed = parse.urlparse(str(file_or_url))
if parsed.scheme:
with request.urlopen(file_or_url) as fio:
tf = tempfile.NamedTemporaryFile(suffix=".ini", dir=tmpdir)
with request.urlopen(str(file_or_url)) as fio:
tf = tempfile.NamedTemporaryFile(suffix=".ini", dir=str(tmpdir))
tf.write(fio.read())
tf.flush()
file = pathlib.Path(tf.name)
Expand Down
3 changes: 0 additions & 3 deletions src/mxdev/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ def tempdir(tmp_path):
os.chdir(cwd)


import httpretty


@pytest.fixture
def src(tempdir):
base = tempdir / "src"
Expand Down
13 changes: 6 additions & 7 deletions src/mxdev/tests/test_common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from .. import vcs
from ..vcs import common
from unittest import mock

import logging
import os
Expand Down Expand Up @@ -28,16 +27,16 @@ def test_BaseWorkingCopy():
common.BaseWorkingCopy(source={})

class TestWorkingCopy(common.BaseWorkingCopy):
def checkout(self, **kwargs) -> typing.Union[str, None]:
def checkout(self, **kwargs) -> typing.Union[str, None]: # type: ignore
...

def status(self, **kwargs) -> typing.Union[typing.Tuple[str, str], str]:
def status(self, **kwargs) -> typing.Union[typing.Tuple[str, str], str]: # type: ignore
...

def matches(self) -> bool:
def matches(self) -> bool: # type: ignore
...

def update(self, **kwargs) -> typing.Union[str, None]:
def update(self, **kwargs) -> typing.Union[str, None]: # type: ignore
...

bwc = TestWorkingCopy(source=dict(url="https://tld.com/repo.git"))
Expand Down Expand Up @@ -163,10 +162,10 @@ def checkout(self, **kwargs) -> typing.Union[str, None]:
def status(self, **kwargs) -> typing.Union[typing.Tuple[str, str], str]:
return self.package_status

def matches(self) -> bool:
def matches(self) -> bool: # type: ignore
...

def update(self, **kwargs) -> typing.Union[str, None]:
def update(self, **kwargs) -> typing.Union[str, None]: # type: ignore
...

class WCT(dict):
Expand Down
5 changes: 3 additions & 2 deletions src/mxdev/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any
from typing import Dict
from typing import Iterable
from typing import Union

import os
import sys
Expand Down Expand Up @@ -120,7 +121,7 @@ def __call__(self, line):
class Process:
"""Process related functions using the tee module."""

def __init__(self, quiet: bool = False, env=None, cwd: str = None):
def __init__(self, quiet: bool = False, env=None, cwd: Union[str, None] = None):
self.quiet = quiet
self.env = env
self.cwd = cwd
Expand Down Expand Up @@ -171,7 +172,7 @@ def add_submodule(self, submodule: "GitRepo", submodule_name: str):
self(f"git add {submodule_name}")
self(f"git commit -m 'Add submodule {submodule_name}'")

def add_branch(self, bname: str, msg: str = None):
def add_branch(self, bname: str, msg: Union[str, None] = None):
self(f"git checkout -b {bname}")


Expand Down
2 changes: 1 addition & 1 deletion src/mxdev/vcs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def print_stderr(s: str):

# taken from
# http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python
def which(name_root: str, default: str = None) -> str:
def which(name_root: str, default: typing.Union[str, None] = None) -> str:
if platform.system() == "Windows":
# http://www.voidspace.org.uk/python/articles/command_line.shtml#pathext
pathext = os.environ["PATHEXT"]
Expand Down

0 comments on commit 0a3f114

Please sign in to comment.