Skip to content
This repository was archived by the owner on Jun 2, 2026. It is now read-only.

Added the ability to use other instances of the mystbin application. - #22

Merged
AbstractUmbra merged 4 commits into
PythonistaGuild:mainfrom
ShadowFox88:main
Dec 28, 2024
Merged

AbstractUmbra merged 4 commits into
PythonistaGuild:mainfrom
ShadowFox88:main

Conversation

@ShadowFox88

Copy link
Copy Markdown
Contributor

Description

This PR adds the ability to use self hosted instances of mystbin. Previously, the code relied on using the instance hosted by the PythonistaGuild at https://mystb.in, and had no way to change this to use any other instances. It keeps backwards compatibility in that it will always default to using https://mystb.in, but can be changed at will. Apologises in advance for any issues with documentation, I have tried to implement it as best as I could.

The code I used to test my changes is below. It is not comprehensive as I do not feel that the scope of what I am adding would have affected any other features, however it should be enough to verify that the code works.

import asyncio

import mystbin

file = mystbin.File(filename="File1.txt", content="Hello there!")
file2 = mystbin.File(filename="test.py", content="print('hello!')")


async def test() -> None:
    client = mystbin.Client()
    paste = await client.create_paste(files=[file, file2])
    print(paste)

async def test_with_custom_url() -> None:
    client = mystbin.Client(api_base="<mystbin instance here: in the form https://example.com>") # this could end with / or without and it works.
    paste = await client.create_paste(files=[file, file2])
    print(paste)

asyncio.run(test())
asyncio.run(test_with_custom_url())

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
    • I have updated the changelog with a quick recap of my changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)
  • I have read and agree to the Developer Certificate of Origin for this contribution

they have been removed from ruff checks, and as such are no longer needed
Made it more natural - it can end in a / or not.
Also fixed some bugs as a result of not adding api_base to __slots__ of HTTPClient.
@AbstractUmbra
AbstractUmbra merged commit 42036aa into PythonistaGuild:main Dec 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants