Replace get_keyring_service by KEYRING_SERVICE class variable#1209
Replace get_keyring_service by KEYRING_SERVICE class variable#1209Lotram wants to merge 3 commits into
Conversation
ryneeverett
left a comment
There was a problem hiding this comment.
Regarding the first commit -- oops! Thanks for catching this.
It isn't clear to me that an exception is justified for get_keyring_service though. Perhaps this would be a good time to eliminate the method in favor of a class property string on which Service.get_secret calls .format(config)?
|
I'm ok with removing One solution would be to use a Another solution would be to make |
|
The computed_field solution seems good. Making this a string rather than a method is the main thing I'd like to see. I'd be ok with that string moving to ServiceConfig, but I wouldn't want to see the |
That test was simply testing each abstract method is defined only once. Reverted to check the number of calls for each abstract method while adding an allowlist, for abstract methods we can call from concrete ones
a86a58a to
d459e7a
Compare
ryneeverett
left a comment
There was a problem hiding this comment.
This is a breaking change to the service API so we need to bump the version to 2.0 (LATEST_API_VERSION, API_VERSION of each service, header of api.rst). I'd also like to see backwards compatibility:
@property
def keyring_service(self) -> str:
service = get_service(self.service).API_VERSION
if service.API_VERSION < 2:
return service.get_keyring_service(self)
return self.KEYRING_SERVICE.format(**self.model_dump())| @property | ||
| def keyring_service(self) -> str: | ||
| return self.KEYRING_SERVICE.format(**self.model_dump()) | ||
|
|
There was a problem hiding this comment.
Can we move this method down below all the class variables with the rest of the methods?
| @@ -16,6 +16,7 @@ | |||
| class PagureConfig(config.ServiceConfig): | |||
| # strictly required | |||
There was a problem hiding this comment.
Let's remove this unnecessary comment which isn't quite accurate any more after this change.
| # strictly required |
First commit
Fix a test in
test_service.py: since this commit the test check each abstract method is defined only once, which does not really make sense. I changed it back to check the number of calls, while adding an allowlist for some abstract methods we do want to call from concrete methods.An alternative could be to simply remove this test, since we already have an exception
Second commit
Replace
Service.get_keyring_serviceby aServiceConfig.KEYRING_SERVICEstring