Skip to content
Myr

Use comprehensions whenever possible

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Hugo Osvaldo Barrera · committed by Nate Prewitt · parent 2c6a842 · Browse files · 7 files+22 added−25 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+22 added−25 removed

  • tests:+2 added−2 removed
  • other:+20 added−23 removed

7 files+22 added−25 removed

modified:requests/adapters.py+1 added-2 removed
127 unmodified lines
128129 self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block)130131 def __getstate__(self):132 return dict((attr, getattr(self, attr, None)) for attr in133 self.__attrs__)132 return {attr: getattr(self, attr, None) for attr in self.__attrs__}133134 def __setstate__(self, state):135 # Can't handle by adding 'proxy_manager' to self.__attrs__ because136 # self.poolmanager uses a lambda function, which isn't pickleable.
398 unmodified lines
modified:requests/cookies.py+15 added-14 removed
442 unmodified lines
443444 By default, the pair of `name` and `value` will be set for the domain ''445 and sent on every request (this is sometimes called a "supercookie").446 """447 result = dict(448 version=0,449 name=name,450 value=value,451 port=None,452 domain='',453 path='/',454 secure=False,455 expires=None,456 discard=True,457 comment=None,458 comment_url=None,459 rest={'HttpOnly': None},460 rfc2109=False,)447 result = {448 'version': 0,449 'name': name,450 'value': value,451 'port': None,452 'domain': '',453 'path': '/',454 'secure': False,455 'expires': None,456 'discard': True,457 'comment': None,458 'comment_url': None,459 'rest': {'HttpOnly': None},460 'rfc2109': False,461 }462463 badargs = set(kwargs) - set(result)464 if badargs:465 err = 'create_cookie() got unexpected keyword arguments: %s'
84 unmodified lines
modified:requests/hooks.py+2 added-2 removed
13 unmodified lines
14HOOKS = ['response']151617def default_hooks():18 return dict((event, []) for event in HOOKS)18 return {event: [] for event in HOOKS}1920# TODO: response is the only one212223def dispatch_hook(key, hooks, hook_data, **kwargs):24 """Dispatches a hook dictionary on a given piece of data."""25 hooks = hooks or dict()25 hooks = hooks or {}26 hooks = hooks.get(key)27 if hooks:28 if hasattr(hooks, '__call__'):29 hooks = [hooks]
5 unmodified lines
modified:requests/models.py+1 added-4 removed
650 unmodified lines
651 # sure the content has been fully read.652 if not self._content_consumed:653 self.content654655 return dict(656 (attr, getattr(self, attr, None))657 for attr in self.__attrs__658 )655 return {attr: getattr(self, attr, None) for attr in self.__attrs__}656657 def __setstate__(self, state):658 for name, value in state.items():659 setattr(self, name, value)
294 unmodified lines
modified:requests/sessions.py+1 added-1 removed
736 unmodified lines
737 for key in keys_to_move:738 self.adapters[key] = self.adapters.pop(key)739740 def __getstate__(self):741 state = dict((attr, getattr(self, attr, None)) for attr in self.__attrs__)741 state = {attr: getattr(self, attr, None) for attr in self.__attrs__}742 return state743744 def __setstate__(self, state):745 for attr, value in state.items():
16 unmodified lines
modified:tests/test_requests.py+1 added-1 removed
862 unmodified lines
863 requests.get(httpbin_secure('status', '200'))864865 def test_urlencoded_get_query_multivalued_param(self, httpbin):866867 r = requests.get(httpbin('get'), params=dict(test=['foo', 'baz']))867 r = requests.get(httpbin('get'), params={'test': ['foo', 'baz']})868 assert r.status_code == 200869 assert r.url == httpbin('get?test=foo&test=baz')870871 def test_form_encoded_post_query_multivalued_element(self, httpbin):
1636 unmodified lines
modified:tests/test_utils.py+1 added-1 removed
663 unmodified lines
664 """665 cookiedict = {'test': 'cookies',666 'good': 'cookies'}667 cj = add_dict_to_cookiejar(cookiejar, cookiedict)668 cookies = dict((cookie.name, cookie.value) for cookie in cj)668 cookies = {cookie.name: cookie.value for cookie in cj}669 assert cookiedict == cookies670671672@pytest.mark.parametrize(
110 unmodified lines