Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 28, 2024

Conversation

ShadowFox88
Copy link
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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants