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

Fix deprecation warnings caused by tests #3727

Conversation

DoctorJohn
Copy link
Member

@DoctorJohn DoctorJohn commented Dec 15, 2024

Description

This PR fixes all deprecation warnings caused directly by our test code bringing our warning count down from 109 to 53.

Running our tests still results in some deprecation warnings but those are the real ones caused by Strawberry code. I'll look at those in a separate PR so that this PR only changes code in /tests.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Summary by Sourcery

Fix deprecation warnings in test code by updating deprecated function calls and argument types, and enhance test assertions to check for result data presence.

Bug Fixes:

  • Fix deprecation warnings in test code by updating deprecated function calls and argument types.

Tests:

  • Update test assertions to check for result data presence and handle deprecation warnings using pytest.deprecated_call.

Copy link
Contributor

sourcery-ai bot commented Dec 15, 2024

Reviewer's Guide by Sourcery

This PR addresses deprecation warnings in test code by updating type hints, assertions, and function signatures. The main changes involve adding proper type annotations for Info parameters, using DirectiveValue for directive parameters, and updating test assertions to explicitly check for result.data presence.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Added proper type hints for Info parameters in resolver functions
  • Updated function signatures to include Info type annotation
  • Replaced generic 'info' parameters with properly typed 'strawberry.Info' parameters
tests/litestar/schema.py
tests/schema/test_info.py
tests/schema/test_arguments.py
Updated directive parameter types to use DirectiveValue
  • Changed directive value parameters from str to DirectiveValue[str]
  • Updated type hints in directive function definitions
tests/schema/test_directives.py
tests/schema/test_extensions.py
tests/schema/test_get_extensions.py
Added explicit result.data assertions in tests
  • Added assert result.data checks before accessing result data
  • Ensures result.data exists before performing assertions on its contents
tests/schema/test_directives.py
tests/schema/test_info.py
Updated deprecated test configurations and assertions
  • Updated pytest.warns to pytest.deprecated_call
  • Added proper deprecation warning message matching
  • Updated test parametrization to handle deprecation contexts
tests/test/test_client.py
tests/fields/test_arguments.py

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @DoctorJohn - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

tests/schema/test_info.py Show resolved Hide resolved
Copy link

codecov bot commented Dec 15, 2024

Codecov Report

Attention: Patch coverage is 98.73418% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.97%. Comparing base (a0573da) to head (4be9c5b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3727      +/-   ##
==========================================
- Coverage   97.02%   96.97%   -0.05%     
==========================================
  Files         503      503              
  Lines       33666    33702      +36     
  Branches     5618     5627       +9     
==========================================
+ Hits        32664    32683      +19     
- Misses        795      809      +14     
- Partials      207      210       +3     

Copy link

codspeed-hq bot commented Dec 15, 2024

CodSpeed Performance Report

Merging #3727 will not alter performance

Comparing DoctorJohn:fix-deprecation-warnings-caused-by-tests (4be9c5b) with main (a0573da)

Summary

✅ 21 untouched benchmarks

Copy link
Member

@bellini666 bellini666 left a comment

Choose a reason for hiding this comment

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

❤️

@DoctorJohn DoctorJohn merged commit 3ec03a7 into strawberry-graphql:main Dec 15, 2024
95 of 96 checks passed
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