✨ Remove default API version and make it manual input#183
Conversation
hillairet
left a comment
There was a problem hiding this comment.
I am very confused.aI thought I already commented on this! Did I forget to press send?
- Do you really want to have to pass on the api version on every single call??? It would be annoying and error prone when it's option! Image some calls being on one API version and others on another version!
- I don't understand why it is impossible to do
Token.api_version = '2023-04'. 🤔
|
I will answer 2 first, yes, it just doesn't work. There are something about ABC behavior that I don't under stand, but I couldn't make it work when writing test for it |
|
I don't see the problem here: from abc import ABC, abstractmethod
from typing import ClassVar, Optional
from pydantic import BaseModel
class Token(ABC, BaseModel):
store_name: str
api_version: ClassVar[Optional[str]] = None
class OfflineTokenABC(Token, ABC):
@abstractmethod
def version(self):
pass
class MyOfflineTokenABC(OfflineTokenABC):
api_version: ClassVar[Optional[str]] = '2023-04'
def version(self):
print(self.api_version)
offline = MyOfflineTokenABC(store_name='potato')
print(offline.api_version)
offline.version()
MyOfflineTokenABC.api_version = '2024-04'
print(offline.api_version)
print(Token.api_version)Output as expected: So two ways of setting the api_version. |
|
I found where I did wrong... |
api_versioninToken, I couldn't found a way to override the field valueapi_versionbe input inexecute_restandexecute_gql, since we construct full url inside the function/adminwhich the oldest supported version will be usedclose #173