Skip to content

fix: properly pass in proxy to http client #1544

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No 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? No Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2023

Conversation

AstreaTSS
Copy link
Member

This also fixes the typehint for the http client

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

This PR makes it so that if no proxy URL and no proxy authentication was passed, the passed proxy to HTTPClient will be None instead of a tuple of (None, None). Having it be (None, None) meant that bool(proxy) was always true, and so triggered a proxy check every time a bot started. My bots sometimes got hung up on this step when starting up (something about the WiFi where I live doesn't like it), so this bypass is nice.

Also, the typehint for HTTPClient's proxy was adjusted to note how either the proxy URL or the proxy auth could be invalid, because why not.

Changes

  • Pass in None instead of a tuple if proxy_url and proxy_auth are None into HTTPClient.
  • Make typehint for HTTPClient more accurate.
    • This could probably be made more accurate through a tuple union type, but I'm lazy and I think this solution is good enough.

Related Issues

Test Scenarios

Start up a bot. Literally. Look at the log and find if it tries to validate the proxy or not - it shouldn't attempt to.

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

This also fixes the typehint for the http client
@silasary silasary merged commit de72911 into interactions-py:unstable Aug 26, 2023
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants