Is that really how a bookshelf work?
"Hello Magic Bookshelf, report status!"
"Bookshelf contain 0 items, remaining capacity is 3"
"Ok, spawn a new item!"
"Ok give me item 0!"
"Here it is, it is The C Programming Language by keringhan & Ritchie"
"Got it. Please spawn another item"
Disclaimer: I'm currently the maintainer of python-telegram-bot.
TBH I haven't tried to understand every detail of what you presented. I'd still like to comment on the design you chose to use methods of your custom classes as callbacks. More precisely I find it rather irritating that you define methods like
It's unstated, so I have to assume that you're using itsdangerous and its implementation of URLSafeTimedSerializer .
with my current design, I am not quite confident how I am going to retrieve the user.email
I'm not sure where the confusion lies. You say you already have the email, from this call:
user_email = s.loads(activation_token)
So maybe ...
I think what i was missing was a "builder" class that could take care of the construction, and allow the interfaces to be returned.
Not all transport types needed to be "started", so i left that concern to the builder of the specific bus (i.e. MQTT transport would have different requirements to Kafka for instance).
I agree with the advice presented by @slepic.
The capacity can be passed as a parameter when a bookshelf is created. The current code treats that capacity as a constant.
If you were to keep that capacity as a property that isn’t asssigned vía constructor method, that value could be set when the property is declared, eliminating the need for the constructor:
To emphasize what Reinderien already said, always check the return of your calls to requests. status_code should return 200. If you get anything else you should stop and investigate. It is possible that the website is blocking you and there is no point running blind.
Also, I recommend that you spoof the user agent, otherwise it is obvious to the web server ...
It's fine for your strings - and scraped web content - to be localised in French; but ensure that your variables are in English (groupe -> group) for consistency
Prefer tuples over lists when you have immutable data
Add PEP484 type hints when possible
Do not leave those first four variables in global scope; move them to a function
Consider using f-strings ...