almonds0166 / pluralkit.py Goto Github PK
View Code? Open in Web Editor NEWAsynchronous Python wrapper for PluralKit's API
License: MIT License
Asynchronous Python wrapper for PluralKit's API
License: MIT License
hi its us again :catresort:
We were messing around with storing json formatted switch data in a cache file, and we were specifically attempting to json.dump()
them as it seemed like the easiest solution for it. But we ran into an issue:
import pluralkit
import json
pk = pluralkit.Client(async_mode=False)
switch = pk.get_switches("exmpl", limit=1)[0]
switch_json = switch.json()
print(switch_json)
# > {... 'members': [MemberId('loxqc'), MemberId('gaznz')]}
json.dumps(switch_json)
# > TypeError: Object of type MemberId is not JSON serializable
The member IDs (which should be strings in this case) are MemberId
objects, and the json library spits them back out because it can't process them.
I believe this is because Model.json()
recursively checks if objects have a json attribute, and stops if not (to avoid trying to convert non-pk objects)
The members in a switch from get_switches
are stored in a list, which doesn't have a json function, so the library skips over them believing it's reached the bottom of the tree.
I'm unsure how this could be solved, but it feels like a bug that should probably be reported.
Heya, is V2 support still planned? It's been out for quite a while now haha
Hi. When i try the example in the docs, I get this error:
Traceback (most recent call last):
File "(file location)", line 3, in <module>
pt = ProxyTag("{", "}")
TypeError: ProxyTag.__init__() missing 1 required keyword-only argument: 'proxy_tag'
For that all I'm trying is:
from pluralkit import ProxyTag
pt = ProxyTag("{", "}")
pt("This is an example.")
Is there something I'm missing, or is this a bug? I'm having similar issues with trying to set proxy tags.
Was trying to test fetching a system other than the token's one so that I didn't have to go add a banner to our own to test something and realised that if the api response returns null
for the privacy then the library fails to construct the system, presumably because it is assumed that the privacy will always be a dictionary when in reality it can be null
│ /home/ringlings/Documents/PluralSnug/venv/lib/python3.10/site-packages/plura │
│ lkit/v2/models.py:783 in __init__ │
│ │
│ 780 │ │ Model.__init__(self, json, ignore_keys) │
│ 781 │ │ # fix up the remaining keys │
│ 782 │ │ self.id = SystemId(id=json["id"], uuid=json["uuid"]) │
│ ❱ 783 │ │ for key, value in json["privacy"].items(): │
│ 784 │ │ │ self.__dict__[key] = Privacy(value) │
│ 785 │
│ 786 class Group(Model): │
╰──────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute 'items'
I'm not sure if there's any way around this but it seems like an oversight that should have attention brought to it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.