Skip to content

Commit 100ea56

Browse files
committed
fix bug with creating File
1 parent 1e36844 commit 100ea56

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import mystbin
5151

5252
mystbin_client = mystbin.Client()
5353

54-
paste = await client.create_paste(filename="Hello.txt", content="Hello there!", syntax="txt")
54+
paste = await client.create_paste(filename="Hello.txt", content="Hello there!")
5555
str(paste)
5656
>>> 'https://mystb.in/<your generated ID>'
5757

@@ -67,8 +67,8 @@ Or if you want to create a paste with multiple files...
6767
```py
6868
import mystbin
6969

70-
file = mystbin.File(filename="File1.txt", content="Hello there!", syntax="txt")
71-
file2 = mystbin.File(filename="test.py", content="print('hello!')", syntax="py")
70+
file = mystbin.File(filename="File1.txt", content="Hello there!")
71+
file2 = mystbin.File(filename="test.py", content="print('hello!')")
7272

7373
paste = await client.create_multifile_paste(files=[file, file2])
7474

mystbin/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
from typing import Literal, NamedTuple
2828

2929
from .client import Client as Client
30+
from .errors import *
3031
from .paste import File as File
3132
from .paste import Paste as Paste
32-
from .errors import *
3333

3434

3535
class VersionInfo(NamedTuple):

mystbin/paste.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class File:
5959
__slots__ = (
6060
"filename",
6161
"content",
62-
"syntax",
6362
"lines_of_code",
6463
"character_count",
6564
)
@@ -87,7 +86,7 @@ def _from_data(cls, payload: FileResponse, /) -> Self:
8786
)
8887

8988
def _to_dict(self) -> dict[str, Any]:
90-
ret: dict[str, Any] = {"content": self.content, "filename": self.filename, "syntax": self.syntax}
89+
ret: dict[str, Any] = {"content": self.content, "filename": self.filename}
9190

9291
return ret
9392

@@ -144,11 +143,15 @@ def __init__(
144143
self.views: Optional[int] = views
145144

146145
def __str__(self) -> str:
147-
return f"https://mystb.in/{self.id}"
146+
return self.url
148147

149148
def __repr__(self) -> str:
150149
return f"<Paste id={self.id!r} files={len(self.files)}>"
151150

151+
@property
152+
def url(self) -> str:
153+
return f"https://mystb.in/{self.id}"
154+
152155
@classmethod
153156
def _from_data(cls, payload: PasteResponse, /) -> Self:
154157
files = [File._from_data(data) for data in payload["files"]]

0 commit comments

Comments
 (0)