Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a get_team function to the platform API #673

Open
slarse opened this issue Sep 10, 2020 · 3 comments
Open

Add a get_team function to the platform API #673

slarse opened this issue Sep 10, 2020 · 3 comments
Labels
enhancement New feature or request plugin

Comments

@slarse
Copy link
Collaborator

slarse commented Sep 10, 2020

Same rationale as #672

@slarse
Copy link
Collaborator Author

slarse commented Jul 26, 2021

I'm thinking we could probably add this as a base function for all APIs, and implement it based in get_teams. I.e. something like:

def get_team(name: str) -> plug.Team:
    return next(iter(self.get_teams(team_names=[name]))

Of course, with some amount of error handling if a team with the given name doesn't exist. The easiest (somewhat dirty) way would probably be to add that method, with implementation, directly in the _APISpec class. That makes _APISpec impure in terms of just being a specification, thoguh, and I don't really like the idea of inheriting functionality in that way.

Perhaps there's a better way using a mixin class or some more magic in the metaclass.

@algomaster99
Copy link
Contributor

I'm thinking we could probably add this as a base function for all APIs

Do you mean adding this implementation in all the APIs which extend from PlatformAPI? That would be a lot of repetitive code, I think.

Should we, instead, implement the method in PlatformAPI so that all the APIs can extend this method as the implementation shall remain the same regardless of the platform? This would also help in throwing an exception if the team does not exist. Also, we wouldn't be making the _APISpec class non-abstract too.

@slarse
Copy link
Collaborator Author

slarse commented Aug 10, 2021

Do you mean adding this implementation in all the APIs which extend from PlatformAPI?

No, I meant for them to inherit it somehow. But I'm not a huge fan of inheritance in that fashion, rather prefer explicit mixin classes.

Should we, instead, implement the method in PlatformAPI

We could, but I like how PlatformAPI doesn't carry any real behavior at the moment. It just wraps the metaclass. But perhaps this is the most pragmatic approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plugin
Projects
None yet
Development

No branches or pull requests

2 participants