Skip to content

Deprecates year argument in espn_cfb_team_coaches#126

Open
bradisbrad wants to merge 2 commits into
mainfrom
125-bug-espn_cfb_team_coaches-always-returning-current-coach
Open

Deprecates year argument in espn_cfb_team_coaches#126
bradisbrad wants to merge 2 commits into
mainfrom
125-bug-espn_cfb_team_coaches-always-returning-current-coach

Conversation

@bradisbrad

@bradisbrad bradisbrad commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Table of Contents generated with DocToc

Pull Request

Summary

Deprecates the year argument in espn_cfb_team_coaches(), as the API only returns the coach for the most recent season regardless of year provided.

Type of Change

  • feat: New feature (e.g. new cfbd_*, espn_cfb_*, or load_cfb_* wrapper)
  • fix: Bug fix
  • docs: Documentation only (roxygen, README, NEWS, vignettes)
  • test: Adding or updating tests (includes the pbp equivalence harness)
  • refactor: Code refactoring (no functional change -- e.g. extracting helpers into R/pbp_*.R)
  • chore: Maintenance / tooling (.Rbuildignore, tools/, lockfiles)
  • perf: Performance improvement
  • ci: GitHub Actions / workflow changes

Related Issues

Closes #125

Background & Context

espn_cfb_team_coaches() no longer provides a list of coaches for a team in a given season and now only returns the coach for the most recent season, even though it returns the year provided to the function. See issue #125 for more details.

Changes Made

File / Resource Change Description
espn_cfb_team_coaches Deprecate year argument
test-cfbd_player_info Adds columns to player_info test

This endpoint still requires a season specification, so I've changed the year argument to default to most_recent_cfb_season(). This argument now kicks a warning if a year other than the most recent season is provided, and the function returns the current year coach to avoid breaking any pipelines using this function.

Submission Checklist

  • Code follows tidyverse style (snake_case, 2-space indent, native pipe |>)
  • Return variables are initialized before any tryCatch block (e.g. df_list <- list(), plays_df <- NULL)
  • Column drops use dplyr::select(-dplyr::any_of(...)); renames use dplyr::rename(dplyr::any_of(c(new = "old")))
  • User-facing messages use cli::cli_alert_*() / cli::cli_warn() / cli::cli_abort() (not message() / stop() / warning())
  • devtools::document() has been run (NAMESPACE updated; no hand-edits to man/ or NAMESPACE)
  • New / changed functions have roxygen with @export, @family, @return, and a runnable example (\donttest{} for live-network calls)
  • Tests added / updated in tests/testthat/ with skip_on_cran() + skip_on_ci() and a skip-if-empty guard right after the API call
  • Column assertions use the subset direction: expect_in(sort(expected), sort(colnames(x)))
  • If touching the 2.3.0 PBP pipeline: test-pbp_equivalence.R still passes (or the allow-list is updated with justification)
  • devtools::check() passes with no errors or warnings
  • NEWS.md updated under the current # **cfbfastR 2.3.0** heading (if user-facing)
  • cran-comments.md updated (if behavioural / user-visible)
  • _pkgdown.yml updated for new exports that need an explicit reference entry (the starts_with("cfbd_") / starts_with("espn_cfb_") selectors pick up most prefix-matching additions automatically)
  • README.Rmd re-rendered with devtools::build_readme() if README content changed
  • DESCRIPTION normalized with usethis::use_tidy_description() if it was edited
  • doctoc TOC re-run if any of NEWS.md / CLAUDE.md / CONTRIBUTING.md / .github/copilot-instructions.md / .github/pull_request_template.md changed
  • Commit messages use conventional commit format (type: description); no AI co-authors

Testing

Describe how you verified these changes work correctly:

  • Tests run locally:
    • devtools::test() (offline -- network tests skip cleanly)
    • devtools::test() with CFBD_API_KEY set (live CFBD)
    • devtools::test() with ESPN connectivity (live espn_cfb_*)
    • tests/testthat/test-pbp_equivalence.R (if you touched PBP / EPA / WPA)
  • Manual smoke calls (paste a couple of representative invocations):
# e.g.
espn_cfb_team_coaches(team_id = 2633)
espn_cfb_team_coaches(team_id = 2633, year = 2011)

Reviewer Checklist

Reviewers: Do not approve until all items are verified

  • Summary clearly explains what this PR does
  • Background & Context provides enough information for someone unfamiliar with the change
  • All changed files are documented with descriptions in the Changes Made table
  • Testing approach is documented and sufficient (offline + live coverage where relevant)
  • Documentation (NEWS.md, cran-comments.md, _pkgdown.yml, roxygen) has been updated or marked N/A with justification
  • Are all items in the PR template completed properly?

Additional Notes

Summary by Sourcery

Deprecate the year parameter in espn_cfb_team_coaches to align with ESPN’s current API behavior and update tests accordingly.

Bug Fixes:

  • Ensure espn_cfb_team_coaches always returns the current season coach and warns when a non-current year is supplied, preventing misleading historical queries.

Enhancements:

  • Default espn_cfb_team_coaches year argument to the most recent CFB season and update its documentation and examples to reflect current-season-only support.
  • Tidy minor formatting and control-flow patterns in various espn_cfb_team helpers for consistency.

Tests:

  • Extend cfbd player info tests to assert presence of new player tenure-related columns.

Summary by CodeRabbit

  • Breaking Changes

    • The college football team coaches endpoint now supports only the current season. Older season values are replaced with the current season and generate a warning.
  • Documentation

    • Updated coaches endpoint guidance and examples to reflect current-season behavior.
  • Tests

    • Added validation for additional player information fields, including active years and team stints.

@bradisbrad bradisbrad linked an issue Jul 18, 2026 that may be closed by this pull request
7 tasks
@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cfbfastr Ready Ready Preview, Comment Jul 18, 2026 8:43pm

Request Review

@sourcery-ai

sourcery-ai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

Deprecates and softens the behavior of the year argument in espn_cfb_team_coaches() to align with ESPN’s current API behavior (only current-season coach is returned), updates its documentation, and slightly cleans up style/tests in related files.

Sequence diagram for updated espn_cfb_team_coaches year handling

sequenceDiagram
  actor User
  participant espn_cfb_team_coaches
  participant most_recent_cfb_season
  participant cli
  participant ESPN_API

  User->>espn_cfb_team_coaches: espn_cfb_team_coaches(team_id, year?)
  alt [year is missing]
    espn_cfb_team_coaches->>most_recent_cfb_season: most_recent_cfb_season()
    most_recent_cfb_season-->>espn_cfb_team_coaches: current_year
  else [year is provided]
    espn_cfb_team_coaches->>most_recent_cfb_season: most_recent_cfb_season()
    most_recent_cfb_season-->>espn_cfb_team_coaches: current_year
    alt [year != current_year]
      espn_cfb_team_coaches->>cli: cli_warn()
      espn_cfb_team_coaches->>espn_cfb_team_coaches: year <- current_year
    end
  end
  espn_cfb_team_coaches->>espn_cfb_team_coaches: validate_year(year)
  espn_cfb_team_coaches->>ESPN_API: GET /seasons/{year}/teams/{team_id}/coaches
  ESPN_API-->>espn_cfb_team_coaches: coach data (current season)
  espn_cfb_team_coaches-->>User: tibble with current season coach
Loading

File-Level Changes

Change Details Files
Deprecate and normalize the year argument behavior in espn_cfb_team_coaches() to always use the most recent CFB season while warning on non-current years.
  • Change espn_cfb_team_coaches() signature so year defaults to most_recent_cfb_season()
  • Keep year parameter but treat it as deprecated in documentation and function contract
  • Add a cli::cli_warn() when a non-current year is supplied and override it to most_recent_cfb_season()
  • Preserve validation for team_id/year and call validate_year(year) after normalization
R/espn_cfb_team.R
man/espn_cfb_team_coaches.Rd
Update documentation and examples for espn_cfb_team_coaches() to reflect current-season-only behavior and deprecated year argument.
  • Revise @description to state that only the current season coach is returned
  • Mark year as deprecated in @param and Rd, documenting the new default
  • Update examples to omit year and demonstrate current usage
  • Ensure Rd usage block matches the new defaulted year argument
R/espn_cfb_team.R
man/espn_cfb_team_coaches.Rd
Minor style/formatting cleanups to other ESPN team helpers and espn_cfb_teams().
  • Adjust argument indentation in several espn_cfb_team_* wrappers for consistent tidyverse style
  • Tighten httr2 pipe indentation in espn_cfb_team_roster() helper
  • Simplify tryCatch handlers in espn_cfb_teams() to empty brace bodies on warning/finally
R/espn_cfb_team.R
Extend cfbd player info tests to assert new player activity columns.
  • Add active_start_year, active_end_year, and team_stints columns to the expected cols vector in test-cfbd_player_info.R
tests/testthat/test-cfbd_player_info.R

Assessment against linked issues

Issue Objective Addressed Explanation
#125 Update espn_cfb_team_coaches() so that it no longer pretends to return historical-season coaches and instead reflects the ESPN API’s current behavior (only the most recent season), including handling of the year argument.
#125 Update the documentation and examples for espn_cfb_team_coaches() to describe that it returns only the current season coach and that the year argument is deprecated/defaults to the most recent season.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

espn_cfb_team_coaches() now targets only the current season, warning and overriding supplied historical years. Its documentation and examples were updated, while unrelated wrapper formatting and CFB player-info test expectations were also changed.

Changes

CFB team updates

Layer / File(s) Summary
Current-season coaches behavior
R/espn_cfb_team.R, man/espn_cfb_team_coaches.Rd
espn_cfb_team_coaches() defaults to most_recent_cfb_season(), warns on non-current years, and documents current-season-only behavior.
Team wrapper formatting
R/espn_cfb_team.R
Argument lists, request pipes, pivot arguments, and tryCatch handlers were reformatted without logic changes.
Player info column expectations
tests/testthat/test-cfbd_player_info.R
The expected columns now include active_start_year, active_end_year, and team_stints.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: saiemgilani

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Several formatting-only edits in unrelated espn_cfb_team wrappers are outside the stated issue and PR objectives. Split the cosmetic wrapper reformatting into a separate PR or document why it is needed for this fix.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: deprecating the year argument in espn_cfb_team_coaches.
Description check ✅ Passed The PR description covers the required template sections and explains the change, issue, context, changes, and testing.
Linked Issues check ✅ Passed The change addresses issue #125 by deprecating year, warning on non-current seasons, and keeping the current coach output.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 125-bug-espn_cfb_team_coaches-always-returning-current-coach

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In espn_cfb_team_coaches(), most_recent_cfb_season() is called multiple times (default arg, comparison, and reassignment); consider caching it in a local current_year variable to avoid redundant calls and potential inconsistencies.
  • This PR introduces several whitespace/indentation-only changes in other team-related functions; it would be cleaner to limit the diff to the coach deprecation changes to keep history focused and make future blame/debugging easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `espn_cfb_team_coaches()`, `most_recent_cfb_season()` is called multiple times (default arg, comparison, and reassignment); consider caching it in a local `current_year` variable to avoid redundant calls and potential inconsistencies.
- This PR introduces several whitespace/indentation-only changes in other team-related functions; it would be cleaner to limit the diff to the coach deprecation changes to keep history focused and make future blame/debugging easier.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/testthat/test-cfbd_player_info.R`:
- Around line 6-7: Update the expanded column assertions in the player-info
tests to verify that the expected fields are a subset of the API response rather
than requiring exact set equality. Apply this change to the assertions around
the listed columns and the corresponding lines 26–28, preserving all required
field names.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cbc43868-56f3-4486-8cd2-7891dcbd6950

📥 Commits

Reviewing files that changed from the base of the PR and between f4681d5 and 1d0474a.

📒 Files selected for processing (3)
  • R/espn_cfb_team.R
  • man/espn_cfb_team_coaches.Rd
  • tests/testthat/test-cfbd_player_info.R

Comment on lines +6 to +7
"home_town", "team_color", "team_color_secondary",
"active_start_year", "active_end_year", "team_stints"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use subset assertions for the expanded column list.

Adding these fields is valid, but expect_setequal() requires the API response to contain exactly this set. Upstream additions will make the test fail; use the required subset direction instead:

Proposed fix
-  expect_setequal(colnames(x), cols)
-  expect_setequal(colnames(y), cols)
-  expect_setequal(colnames(w), cols)
+  expect_in(sort(cols), sort(colnames(x)))
+  expect_in(sort(cols), sort(colnames(y)))
+  expect_in(sort(cols), sort(colnames(w)))

Also applies to: 26-28

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/testthat/test-cfbd_player_info.R` around lines 6 - 7, Update the
expanded column assertions in the player-info tests to verify that the expected
fields are a subset of the API response rather than requiring exact set
equality. Apply this change to the assertions around the listed columns and the
corresponding lines 26–28, preserving all required field names.

Source: Coding guidelines

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.

[bug] espn_cfb_team_coaches always returning current coach

1 participant