Skip to content

Commit

Permalink
Removed type hints for backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
twdragon committed Sep 7, 2023
1 parent 9fa5dff commit 8938ac3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion git-ipfs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import json
LOGICAL_TRUE = ('true', '1', 't', '+')


def recursive_remove(directory: Path) -> None:
def recursive_remove(directory: Path):
for fobj in directory.iterdir():
if fobj.is_dir():
recursive_remove(fobj)
Expand Down
28 changes: 14 additions & 14 deletions git-remote-ipfs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if sys.platform == "win32":
import msvcrt


def stdout_set_binary() -> None:
def stdout_set_binary():
if sys.platform == "win32":
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)

Expand All @@ -28,12 +28,12 @@ class VerbosityType(enum.IntEnum):
DEBUG = 2


def cout(line: str) -> None:
def cout(line: str):
sys.stdout.write(line)
sys.stdout.flush()


def cerr(line: str) -> None:
def cerr(line: str):
sys.stderr.write(line)
sys.stderr.flush()

Expand All @@ -42,22 +42,22 @@ def cin() -> str:
return sys.stdin.readline().strip()


def writeln(msg: str = None) -> None:
def writeln(msg: str = None):
if msg is None:
cout('\n')
else:
cout('{}\n'.format(msg))


def writerr(msg: str = None) -> None:
def writerr(msg: str = None):
if msg is None:
cerr('\n')
else:
cerr('{}\n'.format(msg))


class GitRemoteIpfs:
def __init__(self, rname: str, rpath: str) -> None:
def __init__(self, rname: str, rpath: str):
# CONSTANTS
self.EMPTY_TREE_HASH = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'
# DIRECTORIES
Expand Down Expand Up @@ -172,10 +172,10 @@ Initial configuration not found!
# MISC
self.verbosity = VerbosityType.DEBUG

def ipfs_command(self, command: str) -> str:
def ipfs_command(self, command: str):
return self.ipfs_api_url + '/' + command

def run(self) -> None:
def run(self):
while True:
cmd = cin()
if cmd == 'capabilities':
Expand All @@ -198,14 +198,14 @@ Initial configuration not found!
cerr('Unsupported operation: {}\n'.format(cmd))
sys.exit(1)

def option(self, opt: str) -> None:
def option(self, opt: str):
if opt.startswith('option verbosity'):
self.verbosity = VerbosityType(int(opt[len("option verbosity "):]))
writeln('ok')
else:
writeln('unsupported')

def listing(self, opt: str) -> None:
def listing(self, opt: str):
prepare_push = 'for-push' in opt
references = self.git_references(prepare_push)
for hash, refname in references:
Expand All @@ -219,7 +219,7 @@ Initial configuration not found!
writerr('No default branch on remote {}'.format(self.remote_name))
writeln()

def push(self, opt: str) -> None:
def push(self, opt: str):
remote_head = None
marked_deletion = []
push_objects = {}
Expand Down Expand Up @@ -426,7 +426,7 @@ Total: {}
sys.exit(1)
writeln()

def fetch(self, opt: str) -> None:
def fetch(self, opt: str):
while True:
name, obj_hash, val = opt.split(' ')
if self.verbosity == VerbosityType.DEBUG:
Expand Down Expand Up @@ -537,7 +537,7 @@ Total: {}
api_response = requests.post(self.ipfs_command('cat'), params=req_param, timeout=self.timeout, auth=self.ipfs_api_auth)
return api_response.content.decode('utf-8').split(': ')[1].rstrip()

def reference_names(self, ipfs_prefix) -> list[str]:
def reference_names(self, ipfs_prefix):
result = []
req_param = {
'arg': self.ipfs_path + '/' + ipfs_prefix,
Expand Down Expand Up @@ -565,7 +565,7 @@ Total: {}
'Possibly empty IPFS object {}:{} found on the repository'.format(entry['Name'], entry['Hash']))
return result

def git_references(self, prepare_push: bool) -> list[tuple[str, str]]:
def git_references(self, prepare_push: bool):
writerr('Running stat on remote references')
result = []
if not self.accessible_repo and not prepare_push:
Expand Down

0 comments on commit 8938ac3

Please sign in to comment.