Skip to content

Conversation

@reidhoch
Copy link

@reidhoch reidhoch commented Jan 9, 2026

Added the new Gravity Leaders endpoint. The NBA defines Player Gravity as "Gravity quantifies how much a player pulls defenders towards them above expected, essentially measuring how much attention they draw compared to what the spacing on the floor predicts."

@reidhoch
Copy link
Author

reidhoch commented Jan 9, 2026

@swar Here's an updated PR for only the gravityleaders endpoint.

@reidhoch reidhoch changed the title Added GravityLeaders Endpoint feat: added GravityLeaders Endpoint Jan 9, 2026
@reidhoch
Copy link
Author

reidhoch commented Jan 9, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

Copy link
Contributor

@brandonhawi brandonhawi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments, but awesome work so far.

Perhaps a more philosophical question from a library standpoint, but with this type of data perhaps we'd want to validate at the library level to ensure that users don't query for this data for unsupported past seasons? I'm sure the NBA API itself would error but perhaps the library's error will be more useful?

}

# Initialize dataset attributes
self.league_leaders = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.league_leaders = None
self.leaders = None

For consistency with the nba_api, might be better to just use their nomenclature. What do you think?

Also on a side note, why init to None here? It will always be set in load_response.

)


class GravityLeaders(Endpoint):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably provide this class with a docstring?

Comment on lines +16 to +44
LEADER_FIELDS = (
"PLAYERID",
"FIRSTNAME",
"LASTNAME",
"TEAMID",
"TEAMABBREVIATION",
"TEAMNAME",
"TEAMCITY",
"FRAMES",
"GRAVITYSCORE",
"AVGGRAVITYSCORE",
"ONBALLPERIMETERFRAMES",
"ONBALLPERIMETERGRAVITYSCORE",
"AVGONBALLPERIMETERGRAVITYSCORE",
"OFFBALLPERIMETERFRAMES",
"OFFBALLPERIMETERGRAVITYSCORE",
"AVGOFFBALLPERIMETERGRAVITYSCORE",
"ONBALLINTERIORFRAMES",
"ONBALLINTERIORGRAVITYSCORE",
"AVGONBALLINTERIORGRAVITYSCORE",
"OFFBALLINTERIORFRAMES",
"OFFBALLINTERIORGRAVITYSCORE",
"AVGOFFBALLINTERIORGRAVITYSCORE",
"GAMESPLAYED",
"MINUTES",
"PTS",
"REB",
"AST",
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is consistent with the rest of the codebase, can we consider having a single source of truth for the field names instead of two places (here and in the GravityLeaders class)?

@reidhoch reidhoch requested a review from brandonhawi January 15, 2026 20:01
@reidhoch
Copy link
Author

Hey @brandonhawi please re-review when you get a moment.

@reidhoch
Copy link
Author

@swar / @rsforbes any comments or concerns?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants