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

Convert endpoints to properties #14

Open
baronet2 opened this issue Dec 18, 2021 · 1 comment
Open

Convert endpoints to properties #14

baronet2 opened this issue Dec 18, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@baronet2
Copy link
Owner

baronet2 commented Dec 18, 2021

Returning Endpoint instances rather than storing these as properties introduces unnecessary complexity to the Rider and Race sections. It would be better to return the relevant result directly, or return the raw response if it is not being parsed.

For example,Race(XX).victory_table().table should become Race(XX).victory_table.

Such calls should automatically update properties common to all endpoints of that instance, such as Race(XX).header_details. To avoid losing data, all raw responses should be accessible somehow.

Where we accept parameters for the methods, we can separate these into separate attributes or use dictionary syntax instead. For example, Rider(XX).year_results(2020).results_df should become Rider(XX).year_results[2020].

@baronet2
Copy link
Owner Author

The basic case can be implemented by converting methods to cached_propertys.

To achieve the dictionary syntax, we can inherit from CachedDict below.

class CachedDict(dict):
	def __getitem__(self, key):
		if key not in self:
			value = self.compute_value(key)
			self[key] = value
		return self.get(key)

	def compute_value(self, key):
		# Override this method with desired behaviour
		return None

Not sure yet what the best logical way to store raw responses is.

@baronet2 baronet2 added the enhancement New feature or request label Jun 15, 2022
@baronet2 baronet2 added the help wanted Extra attention is needed label May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant