Skip to content

Commit 334e60e

Browse files
committed
style: fix literal-membership (PLR6201)
1 parent 80fc83b commit 334e60e

9 files changed

Lines changed: 11 additions & 11 deletions

File tree

httoop/authentication/digest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def calculate_request_digest(cls, authinfo: ByteUnicodeDict) -> bytes:
182182

183183
qop = authinfo.get('qop')
184184
hash_a2 = H(cls.A2(authinfo))
185-
if qop in (b'auth', b'auth-int'):
185+
if qop in {b'auth', b'auth-int'}:
186186
data = b'%s:%s:%s:%s:%s' % (authinfo['nonce'], authinfo['nc'], authinfo['cnonce'], authinfo['qop'], hash_a2)
187187
elif qop is None:
188188
data = b'%s:%s' % (authinfo['nonce'], hash_a2)

httoop/codecs/multipart/multipart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def decode(cls, data: bytes, charset: str | None = None, mimetype: ContentType |
3434
if part:
3535
raise DecodeError(_('Data before boundary: %r'), part.decode('ISO8859-1'))
3636
part = parts.pop()
37-
if part not in (b'--', b'--\r\n'):
37+
if part not in {b'--', b'--\r\n'}:
3838
raise DecodeError(_('Invalid multipart end: %r'), part.decode('ISO8859-1'))
3939

4040
from httoop.messages.body import Body

httoop/gateway/wsgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def get_environ(self) -> dict[str, str | tuple[int, int] | WSGIBody | bool | Non
125125
environ.update({
126126
'HTTP_%s' % name.upper().replace('-', '_'): value
127127
for name, value in self.request.headers.items()
128-
if name.lower() not in ('content-type', 'content-length')
128+
if name.lower() not in {'content-type', 'content-length'}
129129
})
130130
environ.update({
131131
'REQUEST_METHOD': str(self.request.method),

httoop/header/conditional.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __int__(self) -> int:
2828
class _MatchElement:
2929

3030
def __eq__(self, other: object) -> bool:
31-
return self.value == other or self.value == '*'
31+
return self.value in {other, '*'}
3232

3333
def matches(self, etag):
3434
return self == etag
@@ -58,7 +58,7 @@ class ETag(HeaderElement):
5858
def __eq__(self, other: object) -> bool:
5959
if not isinstance(other, ETag):
6060
other = self.__class__(other)
61-
return other.value == self.value or other.value == '*'
61+
return other.value in {self.value, '*'}
6262

6363

6464
class LastModified(_DateComparable, HeaderElement):

httoop/header/element.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def parse(cls, elementstr: bytes) -> HeaderElement:
390390
@classmethod
391391
def unescape_key(cls, key: bytes) -> bytes:
392392
key = key.strip()
393-
if key.lower() in (b'httponly', b'secure', b'path', b'domain', b'max-age', b'expires'):
393+
if key.lower() in {b'httponly', b'secure', b'path', b'domain', b'max-age', b'expires'}:
394394
return key.lower()
395395
return key
396396

httoop/semantic/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def prepare(self) -> None:
3333
if 'Host' not in self.message.headers and self.message.uri.host:
3434
self.message.headers['Host'] = self.message.uri.host
3535

36-
if self.message.method in ('PUT', 'POST') and self.message.body and 'Date' not in self.message.headers:
36+
if self.message.method in {'PUT', 'POST'} and self.message.body and 'Date' not in self.message.headers:
3737
self.message.headers['Date'] = bytes(Date()) # RFC 2616 Section 14.18
3838

3939
if self.message.method == 'TRACE':

httoop/semantic/response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def prepare(self) -> None:
2828
response = self.response
2929

3030
status = int(response.status)
31-
if status < 200 or status in (204, 205, 304):
31+
if status < 200 or status in {204, 205, 304}:
3232
# 1XX, 204 NO_CONTENT, 205 RESET_CONTENT, 304 NOT_MODIFIED
3333
response.body = None
3434

httoop/server/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def sanitize_request_uri_path(self) -> None:
105105

106106
def validate_request_uri_scheme(self) -> None:
107107
if self.message.uri.scheme:
108-
if self.message.uri.scheme not in ('http', 'https'): # pragma: no cover
108+
if self.message.uri.scheme not in {'http', 'https'}: # pragma: no cover
109109
exc = InvalidURI(_('Invalid URL: wrong scheme'))
110110
raise BAD_REQUEST(str(exc))
111111
else:
@@ -133,7 +133,7 @@ def check_message_without_body_containing_data(self) -> None:
133133
raise LENGTH_REQUIRED('Missing Content-Length header.')
134134

135135
def check_methods_without_body(self) -> None:
136-
if self.message.method in ('HEAD', 'GET', 'TRACE') and self.message.body:
136+
if self.message.method in {'HEAD', 'GET', 'TRACE'} and self.message.body:
137137
raise BAD_REQUEST(f'A {self.message.method} request is considered as safe and MUST NOT contain a request body.')
138138

139139
def check_http2_upgrade(self) -> None:

tests/authentication/test_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def test_basic_www_authenticate(headers):
88
www_auth = WWWAuthenticate('Basic', {'realm': 'simple'})
9-
assert bytes(www_auth) in (b'Basic realm="simple"', b'Basic realm=simple')
9+
assert bytes(www_auth) in {b'Basic realm="simple"', b'Basic realm=simple'}
1010
headers.parse(b'WWW-Authenticate: %s' % www_auth)
1111
assert headers.elements('WWW-Authenticate')[0].realm == 'simple'
1212

0 commit comments

Comments
 (0)