Giter Club home page Giter Club logo

pluralkit.py's People

Contributors

almonds0166 avatar moon-dew avatar overcastwarmth avatar powertashton avatar vioshim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pluralkit.py's Issues

`Switch.json()` returns `MemberId` objects instead of strings of their IDs

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.

V2 Support?

Heya, is V2 support still planned? It's been out for quite a while now haha

Having issues with proxy tags

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.

Privacy being null in the api response errors

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.