Refine project workflow (#1534)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* Refine project workflow * Fix link to third party packages
authored by Tom Christie · committed by GitHub · parent 1a6e254 · Browse files · 14 files·+388 added−155 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
14 files+388 added−155 removed
- other:+388 added−155 removed
Provenance
- Commit
437b55c- Tree
a0c3e8e- Author
Tom Christie <tom@tomchristie.com>- Committer
GitHub <noreply@github.com>- Parent
1a6e254
14 files changed+388 added−155 removed
added:.github/ISSUE_TEMPLATE/1-issue.md+15 added
123456789101112131415---name: Issueabout: Please only raise an issue if you've been advised to do so after discussion. Thanks! 🙏---
The starting point for issues should usually be [a discussion](https://github.com/encode/httpx/discussions)
Possible bugs may be raised as a "Potential Issue" discussion, feature requests maybe raised as an "Ideas" discussion. We can then determine if the discussion needsto be escalated into an "Issue" or not.
This will help us ensure that the "Issues" list properly reflects ongoing or neededwork on the project.
- [ ] Initially raised as discussion #...deleted:.github/ISSUE_TEMPLATE/2-bug-report.md-61 removed
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061---name: Bug reportabout: Report a bug to help improve this project---
### Checklist
<!-- Please make sure you check all these items before submitting your bug report. -->
- [ ] The bug is reproducible against the latest release and/or `master`.- [ ] There are no similar issues or pull requests to fix it yet.
### Describe the bug
<!-- A clear and concise description of what the bug is. -->
### To reproduce
<!-- Provide a *minimal* example with steps to reproduce the bug locally.
NOTE: try to keep any external dependencies *at an absolute minimum* (servers, proxies, certificates...).In other words, remove anything that doesn't make the bug go away.
If you need a local server to replicate against, you can build one using eg. Starlette [0] and Uvicorn [1], or any tool you feel comfortable with. Check out other issues for examples and remember to share setup instructions here. :-)
[0]: https://www.starlette.io[1]: https://www.uvicorn.org-->
### Expected behavior
<!-- A clear and concise description of what you expected to happen. -->
### Actual behavior
<!-- A clear and concise description of what actually happens. -->
### Debugging material
<!-- Any tracebacks, screenshots, etc. that can help understanding the problem.
NOTE:- Please list tracebacks in full (don't truncate them).- If relevant, consider turning on DEBUG or TRACE logs for additional details (see https://www.python-httpx.org/environment_variables/#httpx_log_level).- Consider using `<details>` to make tracebacks/logs collapsible if they're very large (see https://gist.github.com/ericclemmons/b146fe5da72ca1f706b2ef72a20ac39d).-->
### Environment
- OS: <!-- eg Linux/Windows/macOS. -->- Python version: <!-- eg 3.8.2 (get it with `$ python -V`). -->- HTTPX version: <!-- eg 0.12.0 (get it with `$ pip show httpx`). -->- Async environment: <!-- eg asyncio/trio. If using asyncio, include whether the bug reproduces on trio (and vice versa). -->- HTTP proxy: <!-- yes/no, if yes please try reproducing without it. -->- Custom certificates: <!-- yes/no, if yes please try reproducing without them. If the bug is related to SSL/TLS, you can setup HTTPS on a local server using these instructions: https://www.python-httpx.org/advanced/#making-https-requests-to-a-local-server. -->
### Additional context
<!-- Any additional information that can help understanding the problem.
Eg. linked issues, or a description of what you were trying to achieve. -->deleted:.github/ISSUE_TEMPLATE/3-feature-request.md-34 removed
12345678910111213141516171819202122232425262728293031323334---name: Feature requestabout: Suggest an idea for this project.---
### Checklist
<!-- Please make sure you check all these items before submitting your feature request. -->
- [ ] There are no similar issues or pull requests for this yet.- [ ] I discussed this idea on the [community chat](https://gitter.im/encode/community) and feedback is positive.
### Is your feature related to a problem? Please describe.
<!-- A clear and concise description of what you are trying to achieve.
Eg "I want to be able to [...] but I can't because [...]". -->
## Describe the solution you would like.
<!-- A clear and concise description of what you would want to happen.
For API changes, try to provide a code snippet of what you would like the API to look like.-->
## Describe alternatives you considered
<!-- Please describe any alternative solutions or features you've considered to solveyour problem and why they wouldn't solve it. -->
## Additional context
<!-- Provide any additional context, screenshots, tracebacks, etc. about the feature here. -->
modified:.github/ISSUE_TEMPLATE/config.yml+6 added-2 removed
123445678910711# Ref: https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository#configuring-the-template-chooserblank_issues_enabled: truecontact_links:- name: Question- name: Discussions url: https://github.com/encode/httpx/discussions about: > The "Discussions" forum is where you want to start. 💖- name: Chat url: https://gitter.im/encode/community about: > Ask a question Our community chat forum.added:.github/CONTRIBUTING.md+235 added
1+# Contributing2+3+Thank you for being interested in contributing to HTTPX.4+There are many ways you can contribute to the project:5+6+- Try HTTPX and [report bugs/issues you find](https://github.com/encode/httpx/issues/new)7+- [Implement new features](https://github.com/encode/httpx/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)8+- [Review Pull Requests of others](https://github.com/encode/httpx/pulls)9+- Write documentation10+- Participate in discussions11+12+## Reporting Bugs or Other Issues13+14+Found something that HTTPX should support?15+Stumbled upon some unexpected behaviour?16+17+Contributions should generally start out with [a discussion](https://github.com/encode/httpx/discussions).18+Possible bugs may be raised as a "Potential Issue" discussion, feature requests may19+be raised as an "Ideas" discussion. We can then determine if the discussion needs20+to be escalated into an "Issue" or not, or if we'd consider a pull request.21+22+Try to be more descriptive as you can and in case of a bug report,23+provide as much information as possible like:24+25+- OS platform26+- Python version27+- Installed dependencies and versions (`python -m pip freeze`)28+- Code snippet29+- Error traceback30+31+You should always try to reduce any examples to the *simplest possible case*32+that demonstrates the issue.33+34+Some possibly useful tips for narrowing down potential issues...35+36+- Does the issue exist on HTTP/1.1, or HTTP/2, or both?37+- Does the issue exist with `Client`, `AsyncClient`, or both?38+- When using `AsyncClient` does the issue exist when using `asyncio` or `trio`, or both?39+40+## Development41+42+To start developing HTTPX create a **fork** of the43+[HTTPX repository](https://github.com/encode/httpx) on GitHub.44+45+Then clone your fork with the following command replacing `YOUR-USERNAME` with46+your GitHub username:47+48+```shell49+$ git clone https://github.com/YOUR-USERNAME/httpx50+```51+52+You can now install the project and its dependencies using:53+54+```shell55+$ cd httpx56+$ scripts/install57+```58+59+## Testing and Linting60+61+We use custom shell scripts to automate testing, linting,62+and documentation building workflow.63+64+To run the tests, use:65+66+```shell67+$ scripts/test68+```69+70+!!! warning71+ The test suite spawns testing servers on ports **8000** and **8001**.72+ Make sure these are not in use, so the tests can run properly.73+74+You can run a single test script like this:75+76+```shell77+$ scripts/test -- tests/test_multipart.py78+```79+80+To run the code auto-formatting:81+82+```shell83+$ scripts/lint84+```85+86+Lastly, to run code checks separately (they are also run as part of `scripts/test`), run:87+88+```shell89+$ scripts/check90+```91+92+## Documenting93+94+Documentation pages are located under the `docs/` folder.95+96+To run the documentation site locally (useful for previewing changes), use:97+98+```shell99+$ scripts/docs100+```101+102+## Resolving Build / CI Failures103+104+Once you've submitted your pull request, the test suite will automatically run, and the results will show up in GitHub.105+If the test suite fails, you'll want to click through to the "Details" link, and try to identify why the test suite failed.106+107+<p align="center" style="margin: 0 0 10px">108+ <img src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/gh-actions-fail.png" alt='Failing PR commit status'>109+</p>110+111+Here are some common ways the test suite can fail:112+113+### Check Job Failed114+115+<p align="center" style="margin: 0 0 10px">116+ <img src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/gh-actions-fail-check.png" alt='Failing GitHub action lint job'>117+</p>118+119+This job failing means there is either a code formatting issue or type-annotation issue.120+You can look at the job output to figure out why it's failed or within a shell run:121+122+```shell123+$ scripts/check124+```125+126+It may be worth it to run `$ scripts/lint` to attempt auto-formatting the code127+and if that job succeeds commit the changes.128+129+### Docs Job Failed130+131+This job failing means the documentation failed to build. This can happen for132+a variety of reasons like invalid markdown or missing configuration within `mkdocs.yml`.133+134+### Python 3.X Job Failed135+136+<p align="center" style="margin: 0 0 10px">137+ <img src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/gh-actions-fail-test.png" alt='Failing GitHub action test job'>138+</p>139+140+This job failing means the unit tests failed or not all code paths are covered by unit tests.141+142+If tests are failing you will see this message under the coverage report:143+144+`=== 1 failed, 435 passed, 1 skipped, 1 xfailed in 11.09s ===`145+146+If tests succeed but coverage doesn't reach our current threshold, you will see this147+message under the coverage report:148+149+`FAIL Required test coverage of 100% not reached. Total coverage: 99.00%`150+151+## Releasing152+153+*This section is targeted at HTTPX maintainers.*154+155+Before releasing a new version, create a pull request that includes:156+157+- **An update to the changelog**:158+ - We follow the format from [keepachangelog](https://keepachangelog.com/en/1.0.0/).159+ - [Compare](https://github.com/encode/httpx/compare/) `master` with the tag of the latest release, and list all entries that are of interest to our users:160+ - Things that **must** go in the changelog: added, changed, deprecated or removed features, and bug fixes.161+ - Things that **should not** go in the changelog: changes to documentation, tests or tooling.162+ - Try sorting entries in descending order of impact / importance.163+ - Keep it concise and to-the-point. 🎯164+- **A version bump**: see `__version__.py`.165+166+For an example, see [#1006](https://github.com/encode/httpx/pull/1006).167+168+Once the release PR is merged, create a169+[new release](https://github.com/encode/httpx/releases/new) including:170+171+- Tag version like `0.13.3`.172+- Release title `Version 0.13.3`173+- Description copied from the changelog.174+175+Once created this release will be automatically uploaded to PyPI.176+177+If something goes wrong with the PyPI job the release can be published using the178+`scripts/publish` script.179+180+## Development proxy setup181+182+To test and debug requests via a proxy it's best to run a proxy server locally.183+Any server should do but HTTPCore's test suite uses184+[`mitmproxy`](https://mitmproxy.org/) which is written in Python, it's fully185+featured and has excellent UI and tools for introspection of requests.186+187+You can install `mitmproxy` using `pip install mitmproxy` or [several188+other ways](https://docs.mitmproxy.org/stable/overview-installation/).189+190+`mitmproxy` does require setting up local TLS certificates for HTTPS requests,191+as its main purpose is to allow developers to inspect requests that pass through192+it. We can set them up follows:193+194+1. [`pip install trustme-cli`](https://github.com/sethmlarson/trustme-cli/).195+2. `trustme-cli -i example.org www.example.org`, assuming you want to test196+connecting to that domain, this will create three files: `server.pem`,197+`server.key` and `client.pem`.198+3. `mitmproxy` requires a PEM file that includes the private key and the199+certificate so we need to concatenate them:200+`cat server.key server.pem > server.withkey.pem`.201+4. Start the proxy server `mitmproxy --certs server.withkey.pem`, or use the202+[other mitmproxy commands](https://docs.mitmproxy.org/stable/) with different203+UI options.204+205+At this point the server is ready to start serving requests, you'll need to206+configure HTTPX as described in the207+[proxy section](https://www.python-httpx.org/advanced/#http-proxying) and208+the [SSL certificates section](https://www.python-httpx.org/advanced/#ssl-certificates),209+this is where our previously generated `client.pem` comes in:210+211+```212+import httpx213+214+proxies = {"all": "http://127.0.0.1:8080/"}215+216+with httpx.Client(proxies=proxies, verify="/path/to/client.pem") as client:217+ response = client.get("https://example.org")218+ print(response.status_code) # should print 200219+```220+221+Note, however, that HTTPS requests will only succeed to the host specified222+in the SSL/TLS certificate we generated, HTTPS requests to other hosts will223+raise an error like:224+225+```226+ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate227+verify failed: Hostname mismatch, certificate is not valid for228+'duckduckgo.com'. (_ssl.c:1108)229+```230+231+If you want to make requests to more hosts you'll need to regenerate the232+certificates and include all the hosts you intend to connect to in the233+seconds step, i.e.234+235+`trustme-cli -i example.org www.example.org duckduckgo.com www.duckduckgo.com`added:.github/FUNDING.yml+1 added
1github: encodeadded:.github/PULL_REQUEST_TEMPLATE.md+9 added
123456789The starting point for contributions should usually be [a discussion](https://github.com/encode/httpx/discussions)
Simple documentation typos may be raised as stand-alone pull requests, but otherwiseplease ensure you've discussed the your proposal prior to issuing a pull request.
This will help us direct work appropriately, and ensure that any suggested changeshave been okayed by the maintainers.
- [ ] Initially raised as discussion #...added:docs/code_of_conduct.md+56 added
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556# Code of Conduct
We expect contributors to our projects and online spaces to follow [the Python Software Foundation’s Code of Conduct](https://www.python.org/psf/conduct/).
The Python community is made up of members from around the globe with a diverse set of skills, personalities, and experiences. It is through these differences that our community experiences great successes and continued growth. When you're working with members of the community, this Code of Conduct will help steer your interactions and keep Python a positive, successful, and growing community.
## Our Community
Members of the Python community are **open, considerate, and respectful**. Behaviours that reinforce these values contribute to a positive environment, and include:
* **Being open.** Members of the community are open to collaboration, whether it's on PEPs, patches, problems, or otherwise.* **Focusing on what is best for the community.** We're respectful of the processes set forth in the community, and we work within them.* **Acknowledging time and effort.** We're respectful of the volunteer efforts that permeate the Python community. We're thoughtful when addressing the efforts of others, keeping in mind that often times the labor was completed simply for the good of the community.* **Being respectful of differing viewpoints and experiences.** We're receptive to constructive comments and criticism, as the experiences and skill sets of other members contribute to the whole of our efforts.* **Showing empathy towards other community members.** We're attentive in our communications, whether in person or online, and we're tactful when approaching differing views.* **Being considerate.** Members of the community are considerate of their peers -- other Python users.* **Being respectful.** We're respectful of others, their positions, their skills, their commitments, and their efforts.* **Gracefully accepting constructive criticism.** When we disagree, we are courteous in raising our issues.* **Using welcoming and inclusive language.** We're accepting of all who wish to take part in our activities, fostering an environment where anyone can participate and everyone can make a difference.
## Our Standards
Every member of our community has the right to have their identity respected. The Python community is dedicated to providing a positive experience for everyone, regardless of age, gender identity and expression, sexual orientation, disability, physical appearance, body size, ethnicity, nationality, race, or religion (or lack thereof), education, or socio-economic status.
## Inappropriate Behavior
Examples of unacceptable behavior by participants include:
* Harassment of any participants in any form* Deliberate intimidation, stalking, or following* Logging or taking screenshots of online activity for harassment purposes* Publishing others' private information, such as a physical or electronic address, without explicit permission* Violent threats or language directed against another person* Incitement of violence or harassment towards any individual, including encouraging a person to commit suicide or to engage in self-harm* Creating additional online accounts in order to harass another person or circumvent a ban* Sexual language and imagery in online communities or in any conference venue, including talks* Insults, put downs, or jokes that are based upon stereotypes, that are exclusionary, or that hold others up for ridicule* Excessive swearing* Unwelcome sexual attention or advances* Unwelcome physical contact, including simulated physical contact (eg, textual descriptions like "hug" or "backrub") without consent or after a request to stop* Pattern of inappropriate social contact, such as requesting/assuming inappropriate levels of intimacy with others* Sustained disruption of online community discussions, in-person presentations, or other in-person events* Continued one-on-one communication after requests to cease* Other conduct that is inappropriate for a professional audience including people of many different backgrounds
Community members asked to stop any inappropriate behavior are expected to comply immediately.
## Enforcement
We take Code of Conduct violations seriously, and will act to ensure our spaces are welcoming, inclusive, and professional environments to communicate in.
If you need to raise a Code of Conduct report, you may do so privately by email to tom@tomchristie.com.
Reports will be treated confidentially.
Alternately you may [make a report to the Python Software Foundation](https://www.python.org/psf/conduct/reporting/).modified:docs/contributing.md+15 added-3 removed
10 unmodified lines11 12 ## Reporting Bugs or Other Issues13 14 Found something that HTTPX should support?15-Stumbled upon some unexpected behavior?15+Stumbled upon some unexpected behaviour?16 17-Feel free to open an issue at the18-[issue tracker](https://github.com/encode/httpx/issues).17+Contributions should generally start out with [a discussion](https://github.com/encode/httpx/discussions).18+Possible bugs may be raised as a "Potential Issue" discussion, feature requests may19+be raised as an "Ideas" discussion. We can then determine if the discussion needs20+to be escalated into an "Issue" or not, or if we'd consider a pull request.21+22 Try to be more descriptive as you can and in case of a bug report,23 provide as much information as possible like:24 25 - OS platform1 unmodified line27 - Installed dependencies and versions (`python -m pip freeze`)28 - Code snippet29 - Error traceback30 31+You should always try to reduce any examples to the *simplest possible case*32+that demonstrates the issue.33+34+Some possibly useful tips for narrowing down potential issues...35+36+- Does the issue exist on HTTP/1.1, or HTTP/2, or both?37+- Does the issue exist with `Client`, `AsyncClient`, or both?38+- When using `AsyncClient` does the issue exist when using `asyncio` or `trio`, or both?39+40 ## Development41 42 To start developing HTTPX create a **fork** of the43 [HTTPX repository](https://github.com/encode/httpx) on GitHub.192 unmodified linesmodified:docs/index.md+1 added-1 removed
99 unmodified lines100 the [async support](async.md) section, or the [HTTP/2](http2.md) section.101 102 The [Developer Interface](api.md) provides a comprehensive API reference.103 104-To find out about tools that integrate with HTTPX, see [Third Party Packages](third-party-packages.md).104+To find out about tools that integrate with HTTPX, see [Third Party Packages](third_party_packages.md).105 106 ## Dependencies107 108 The HTTPX project relies on these excellent libraries:37 unmodified linesadded:docs/third_party_packages.md+48 added
1+# Third Party Packages2+3+As HTTPX usage grows, there is an expanding community of developers building tools and libraries that integrate with HTTPX, or depend on HTTPX. Here are some of them.4+5+## Plugins6+7+<!-- NOTE: this list is in alphabetical order. -->8+9+### Authlib10+11+[GitHub](https://github.com/lepture/authlib) - [Documentation](https://docs.authlib.org/en/latest/)12+13+The ultimate Python library in building OAuth and OpenID Connect clients and servers. Includes an [OAuth HTTPX client](https://docs.authlib.org/en/latest/client/httpx.html).14+15+### Gidgethub16+17+[GitHub](https://github.com/brettcannon/gidgethub) - [Documentation](https://gidgethub.readthedocs.io/en/latest/index.html)18+19+An asynchronous GitHub API library. Includes [HTTPX support](https://gidgethub.readthedocs.io/en/latest/httpx.html).20+21+### RESPX22+23+[GitHub](https://github.com/lundberg/respx) - [Documentation](https://lundberg.github.io/respx/)24+25+A utility for mocking out the Python HTTPX library.26+27+### rpc.py28+29+[Github](https://github.com/abersheeran/rpc.py) - [Documentation](https://github.com/abersheeran/rpc.py#rpcpy)30+31+An fast and powerful RPC framework based on ASGI/WSGI. Use HTTPX as the client of the RPC service.32+33+### VCR.py34+35+[GitHub](https://github.com/kevin1024/vcrpy) - [Documentation](https://vcrpy.readthedocs.io/)36+37+A utility for record and repeat an http request.38+39+40+## Gists41+42+<!-- NOTE: this list is in alphabetical order. -->43+44+### urllib3-transport45+46+[GitHub](https://gist.github.com/florimondmanca/d56764d78d748eb9f73165da388e546e)47+48+This public gist provides an example implementation for a [custom transport](advanced.md#custom-transports) implementation on top of the battle-tested [`urllib3`](https://urllib3.readthedocs.io) library.deleted:docs/third-party-packages.md-48 removed
1-# Third Party Packages2-3-As HTTPX usage grows, there is an expanding community of developers building tools and libraries that integrate with HTTPX, or depend on HTTPX. Here are some of them.4-5-## Plugins6-7-<!-- NOTE: this list is in alphabetical order. -->8-9-### Authlib10-11-[GitHub](https://github.com/lepture/authlib) - [Documentation](https://docs.authlib.org/en/latest/)12-13-The ultimate Python library in building OAuth and OpenID Connect clients and servers. Includes an [OAuth HTTPX client](https://docs.authlib.org/en/latest/client/httpx.html).14-15-### Gidgethub16-17-[GitHub](https://github.com/brettcannon/gidgethub) - [Documentation](https://gidgethub.readthedocs.io/en/latest/index.html)18-19-An asynchronous GitHub API library. Includes [HTTPX support](https://gidgethub.readthedocs.io/en/latest/httpx.html).20-21-### RESPX22-23-[GitHub](https://github.com/lundberg/respx) - [Documentation](https://lundberg.github.io/respx/)24-25-A utility for mocking out the Python HTTPX library.26-27-### rpc.py28-29-[Github](https://github.com/abersheeran/rpc.py) - [Documentation](https://github.com/abersheeran/rpc.py#rpcpy)30-31-An fast and powerful RPC framework based on ASGI/WSGI. Use HTTPX as the client of the RPC service.32-33-### VCR.py34-35-[GitHub](https://github.com/kevin1024/vcrpy) - [Documentation](https://vcrpy.readthedocs.io/)36-37-A utility for record and repeat an http request.38-39-40-## Gists41-42-<!-- NOTE: this list is in alphabetical order. -->43-44-### urllib3-transport45-46-[GitHub](https://gist.github.com/florimondmanca/d56764d78d748eb9f73165da388e546e)47-48-This public gist provides an example implementation for a [custom transport](advanced.md#custom-transports) implementation on top of the battle-tested [`urllib3`](https://urllib3.readthedocs.io) library.deleted:CONTRIBUTING.md-5 removed
1-#### Thanks for considering contributing to HTTPX!2-3-Our [documentation on contributing to HTTPX](https://www.encode.io/httpx/contributing/)4-contains information on how to report bugs, write and test new features, and5-debug issues with your own changes.modified:mkdocs.yml+2 added-1 removed
18 unmodified lines19 - Requests Compatibility: 'compatibility.md'20 - Developer Interface: 'api.md'21 - Exceptions: 'exceptions.md'22 - Troubleshooting: 'troubleshooting.md'23- - Third Party Packages: 'third-party-packages.md'23+ - Third Party Packages: 'third_party_packages.md'24 - Contributing: 'contributing.md'25+ - Code of Conduct: 'code_of_conduct.md'26 27 markdown_extensions:28 - admonition29 - codehilite:9 unmodified lines