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

chore(models): add type hints to improve type safety #6769

Closed
wants to merge 1 commit into from

Conversation

deyjoy
Copy link

@deyjoy deyjoy commented Jul 20, 2024

Summary

This pull request adds type hints to the models.py file in the requests library. The goal is to improve code readability and maintainability by specifying the expected types for function arguments and return values.

Changes

  • Added type hints to all functions and methods in models.py.

Checklist

  • Add type hints to function signatures.
  • Run tests to verify no breaking changes.

Testing

All existing tests were run to ensure that adding type hints did not introduce any breaking changes. The test results are as follows:

  • 602 tests passed
  • 3 tests skipped
  • 1 test expected to fail (xfail)
  • 18 warnings

Warnings

The following warnings were noted during testing:

  • DeprecationWarning: Non-string usernames will no longer be supported in Requests 3.0.0.
  • DeprecationWarning: Non-string passwords will no longer be supported in Requests 3.0.0.
  • DeprecationWarning: In requests 3.0, get_encodings_from_content will be removed.
  • InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised.

These warnings do not impact the functionality of this PR but should be addressed in future updates.

Added type hints to functions and methods in the `models.py` file. This enhances code readability and ensures type safety throughout the codebase. The changes include annotations for return types and function parameters.
@nateprewitt
Copy link
Member

Thanks for the PR, @deyjoy. Typing for Requests is already available in typeshed as stubs. We likely won't be adding inline typing to Requests in the near future.

@deyjoy
Copy link
Author

deyjoy commented Jul 21, 2024

Thank you for the update, @nateprewitt. I understand that inline typing won't be added as typings are already available in typeshed stubs. I appreciate the feedback and the chance to contribute. I will look for other areas where I can assist. If there are any specific needs or suggestions, please let me know. Thanks again for the opportunity!

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