You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/12/19 00:41:11 UTC
[GitHub] [airflow] kaxil opened a new pull request #13171: Replace assignment with augmented assignment
kaxil opened a new pull request #13171:
URL: https://github.com/apache/airflow/pull/13171
`HTTPSConnection.default_socket_options += socket_options` instead of `HTTPSConnection.default_socket_options = HTTPSConnection.default_socket_options + socket_options`
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] XD-DENG commented on pull request #13171: Replace assignment with augmented assignment
Posted by GitBox <gi...@apache.org>.
XD-DENG commented on pull request #13171:
URL: https://github.com/apache/airflow/pull/13171#issuecomment-748461705
This is actually more tricky than it looks, because:
- `urllib3.connection.HTTPSConnection` is child class of `urllib3.connection.HTTPConnection` ([ref](https://urllib3.readthedocs.io/en/latest/reference/urllib3.connection.html#urllib3.connection.HTTPConnection.default_socket_options))
- augmented assignment has special handling on classes and block scopes ([ref](https://www.python.org/dev/peps/pep-0577/#augmented-assignment-to-names-in-block-scopes))
For example, below I have two chunks of identical code with only one difference (using augmented assignment or not), inside I try to update for **HTTPS** connection, then also check **HTTP** connection.
### Original Code
```python
from urllib3.connection import HTTPConnection, HTTPSConnection
socket_options = [
(6,6,6),
(8,8,8)
]
HTTPSConnection.default_socket_options = HTTPSConnection.default_socket_options + socket_options
print(HTTPSConnection.default_socket_options)
print(HTTPConnection.default_socket_options)
```
It prints
```
[(6, 1, 1), (6, 6, 6), (8, 8, 8)]
[(6, 1, 1)]
```
### Using augmented assignment
```python
from urllib3.connection import HTTPConnection, HTTPSConnection
socket_options = [
(6,6,6),
(8,8,8)
]
HTTPSConnection.default_socket_options += socket_options
print(HTTPSConnection.default_socket_options)
print(HTTPConnection.default_socket_options)
```
It prints
```
[(6, 1, 1), (6, 6, 6), (8, 8, 8)]
[(6, 1, 1), (6, 6, 6), (8, 8, 8)]
```
So I would like to suggest abandoning this change. Let me know your thoughts on this?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil closed pull request #13171: Replace assignment with augmented assignment
Posted by GitBox <gi...@apache.org>.
kaxil closed pull request #13171:
URL: https://github.com/apache/airflow/pull/13171
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] XD-DENG commented on pull request #13171: Replace assignment with augmented assignment
Posted by GitBox <gi...@apache.org>.
XD-DENG commented on pull request #13171:
URL: https://github.com/apache/airflow/pull/13171#issuecomment-748458819
I haven't figured out why yet, but this change appends the `socket_options ` into `HTTPSConnection.default_socket_options`/`HTTPConnection.default_socket_options` for two times (while it should be once only), which is causing the CI failure.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil commented on pull request #13171: Replace assignment with augmented assignment
Posted by GitBox <gi...@apache.org>.
kaxil commented on pull request #13171:
URL: https://github.com/apache/airflow/pull/13171#issuecomment-748465808
Yup I agree
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org