Skip to content

Commit d335551

Browse files
caseneuvefiliplajszczak
authored andcommitted
#29 fix typing. by: Filip, Piotr
1 parent 8d9a432 commit d335551

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

cli/path.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import re
22
import sys
3-
from typing import Tuple
43

54
from collections import namedtuple
65
from pprint import pprint
@@ -13,7 +12,7 @@
1312
app = typer.Typer()
1413

1514

16-
def setup(path: str, quiet: bool) -> Tuple[str, PAPath]:
15+
def setup(path: str, quiet: bool) -> PAPath:
1716
logger = get_logger(set_info=True)
1817
if quiet:
1918
logger.disabled = True
@@ -44,7 +43,7 @@ def get(
4443
if contents is None:
4544
sys.exit(1)
4645

47-
if raw or type(contents) == str:
46+
if raw or isinstance(contents, str):
4847
{dict: pprint, str: print}[type(contents)](contents)
4948
sys.exit()
5049

pythonanywhere/files.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ def __repr__(self):
4747
def _make_sharing_url(self, path):
4848
return urljoin(self.api.base_url.split("api")[0], path)
4949

50-
def _standarize_path(self, path):
50+
@staticmethod
51+
def _standarize_path(path):
5152
return path.replace("~", f"/home/{getpass.getuser()}") if path.startswith("~") else path
5253

53-
5454
@property
5555
def url(self):
5656
"""Returns url to PythonAnywhere for `self.path`. Does not
@@ -81,7 +81,7 @@ def contents(self):
8181

8282
try:
8383
content = self.api.path_get(self.path)
84-
return content if type(content) == dict else content.decode("utf-8")
84+
return content if isinstance(content, dict) else content.decode("utf-8")
8585
except Exception as e:
8686
logger.warning(snakesay(str(e)))
8787
return None

pythonanywhere/files.pyi

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1-
from typing import List, Optional, Union
1+
from typing import Optional, Union
2+
3+
from typer import FileBinaryRead
4+
5+
from pythonanywhere.api.files_api import Files
26

3-
from typing_extensions import Literal
47

58
class PAPath:
9+
path: str = ...
10+
api: Files = ...
611
def __init__(self, path: str) -> None: ...
712
def __repr__(self) -> str: ...
13+
def _make_sharing_url(self, path: str) -> str: ...
14+
@staticmethod
15+
def _standarize_path(path: str) -> str: ...
16+
@property
17+
def url(self) -> str: ...
18+
@property
819
def contents(self) -> Optional[Union[dict, str]]: ...
20+
@property
921
def tree(self) -> Optional[list]: ...
1022
def delete(self) -> bool: ...
11-
def upload(self, content: bytes) -> bool: ...
23+
def upload(self, content: FileBinaryRead) -> bool: ...
1224
def get_sharing_url(self) -> str: ...
1325
def share(self) -> str: ...
1426
def unshare(self) -> bool: ...

0 commit comments

Comments
 (0)