Skip to content

Commit

Permalink
- Drop support for Python 3.6 (vcrpy needs >=4.3.0 for Py 3.11, so we…
Browse files Browse the repository at this point in the history
… can't support both)

- Run `pyupgrade` again, this time with 3.7+
- Make sure setup.py install_requires matches requirements.txt
  • Loading branch information
WinterPhoenix committed Sep 13, 2024
1 parent 5e16160 commit 29c5cbc
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing_initiative.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-13, windows-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
no-coverage: [0]
include:
- os: ubuntu-20.04
Expand Down
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

-r requirements.txt

vcrpy==4.3.0
vcrpy==4.4.0 # TODO: 5.0.0 drops support for Python 3.7
PyYAML>=5.4
mock==1.3.0
coverage>=5.0
Expand Down
4 changes: 2 additions & 2 deletions generate_enums_from_proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@

for class_name, (attrs, attrs_starting_with_number) in sorted(classes.items(), key=lambda x: x[0].lower()):
if attrs_starting_with_number:
print("\n{} = SteamIntEnum({!r}, {{".format(class_name, class_name))
print(f"\n{class_name} = SteamIntEnum({class_name!r}, {{")
for ikey, ivalue in attrs.items():
print(" {!r}: {!r},".format(ikey, ivalue))
print(f" {ikey!r}: {ivalue!r},")
print(" })")
else:
print(f"\nclass {class_name}(SteamIntEnum):")
Expand Down
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
pycryptodomex>=3.7.0
requests>=2.9.1
urllib3<2
vdf @ git+https://github.com/solsticegamestudios/vdf
urllib3<2 # See https://github.com/kevin1024/vcrpy/pull/699#issuecomment-1551439663
vdf @ git+https://github.com/solsticegamestudios/[email protected]
cachetools>=3.0.0

gevent>=1.3.0
protobuf~=3.0
gevent-eventemitter~=2.1
cachetools>=3.0.0
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
install_requires = [
'pycryptodomex>=3.7.0',
'requests>=2.9.1',
'urllib3<2',
'vdf>=3.3',
'urllib3<2', # See https://github.com/kevin1024/vcrpy/pull/699#issuecomment-1551439663
'vdf @ git+https://github.com/solsticegamestudios/[email protected]',
'cachetools>=3.0.0',
]

Expand All @@ -38,20 +38,19 @@
author="Rossen Georgiev / Solstice Game Studios",
author_email='[email protected]',
license='MIT',
python_requires=">=3.6",
python_requires=">=3.7",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Natural Language :: English',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
#'Programming Language :: Python :: 3.12', # TODO: Needs vcrpy>=6.0.0
'Programming Language :: Python :: Implementation :: PyPy',
],
keywords='valve steam steamid api webapi steamcommunity',
Expand Down
12 changes: 6 additions & 6 deletions steam/client/cdn.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def get_content_servers_from_cs(cell_id, host='cs.steamcontent.com', port=80, nu
"""
proto = 'https' if port == 443 else 'http'

url = '{}://{}:{}/serverlist/{}/{}/'.format(proto, host, port, cell_id, num_servers)
url = f'{proto}://{host}:{port}/serverlist/{cell_id}/{num_servers}/'
session = make_requests_session() if session is None else session
resp = session.get(url)

Expand Down Expand Up @@ -598,7 +598,7 @@ def get_chunk(self, app_id, depot_id, chunk_id):
:raises SteamError: error message
"""
if (depot_id, chunk_id) not in self._chunk_cache:
resp = self.cdn_cmd('depot', '{}/chunk/{}'.format(depot_id, chunk_id))
resp = self.cdn_cmd('depot', f'{depot_id}/chunk/{chunk_id}')

data = symmetric_decrypt(resp.content, self.get_depot_key(app_id, depot_id))

Expand Down Expand Up @@ -661,7 +661,7 @@ def get_manifest_request_code(self, app_id, depot_id, manifest_gid, branch='publ
)

if resp is None or resp.header.eresult != EResult.OK:
raise SteamError("Failed to get manifest code for {}, {}, {}".format(app_id, depot_id, manifest_gid),
raise SteamError(f"Failed to get manifest code for {app_id}, {depot_id}, {manifest_gid}",
EResult.Timeout if resp is None else EResult(resp.header.eresult))

return resp.body.manifest_request_code
Expand All @@ -684,9 +684,9 @@ def get_manifest(self, app_id, depot_id, manifest_gid, decrypt=True, manifest_re
"""
if (app_id, depot_id, manifest_gid) not in self.manifests:
if manifest_request_code:
resp = self.cdn_cmd('depot', '{}/manifest/{}/5/{}'.format(depot_id, manifest_gid, manifest_request_code))
resp = self.cdn_cmd('depot', f'{depot_id}/manifest/{manifest_gid}/5/{manifest_request_code}')
else:
resp = self.cdn_cmd('depot', '{}/manifest/{}/5'.format(depot_id, manifest_gid))
resp = self.cdn_cmd('depot', f'{depot_id}/manifest/{manifest_gid}/5')

if resp.ok:
manifest = self.DepotManifestClass(self, app_id, resp.content)
Expand Down Expand Up @@ -757,7 +757,7 @@ def get_manifests(self, app_id, branch='public', password=None, filter_func=None
is_enc_branch = False

if branch not in depots.get('branches', {}):
raise SteamError("No branch named {} for app_id {}".format(repr(branch), app_id))
raise SteamError(f"No branch named {repr(branch)} for app_id {app_id}")
elif int(depots['branches'][branch].get('pwdrequired', 0)) > 0:
is_enc_branch = True

Expand Down
4 changes: 2 additions & 2 deletions steam/core/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def send(self, message):
message.sessionID = self.session_id

if self.verbose_debug:
self._LOG.debug("Outgoing: {}\n{}".format(repr(message), str(message)))
self._LOG.debug(f"Outgoing: {repr(message)}\n{str(message)}")
else:
self._LOG.debug("Outgoing: %s", repr(message))

Expand Down Expand Up @@ -277,7 +277,7 @@ def _parse_message(self, message):
msg.parse()

if self.verbose_debug:
self._LOG.debug("Incoming: {}\n{}".format(repr(msg), str(msg)))
self._LOG.debug(f"Incoming: {repr(msg)}\n{str(msg)}")
else:
self._LOG.debug("Incoming: %s", repr(msg))

Expand Down
4 changes: 2 additions & 2 deletions steam/core/msg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __repr__(self):
else:
suffix = 'n/a'

return "<Msg({!r} | {})>".format(self.msg, suffix)
return f"<Msg({self.msg!r} | {suffix})>"

def __str__(self):
rows = [repr(self)]
Expand Down Expand Up @@ -238,7 +238,7 @@ def __repr__(self):
else:
suffix = 'n/a'

return "<MsgProto({!r} | {})>".format(self.msg, suffix)
return f"<MsgProto({self.msg!r} | {suffix})>"

def __str__(self):
rows = [repr(self)]
Expand Down
2 changes: 1 addition & 1 deletion steam/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(self, message, eresult=EResult.Fail):
self.eresult = EResult(eresult) #: :class:`.EResult`

def __str__(self):
return "({}) {}".format(self.eresult, self.message)
return f"({self.eresult}) {self.message}"

class ManifestError(SteamError):
"""
Expand Down
2 changes: 1 addition & 1 deletion steam/game_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def query_master(filter_text=r'\nappid\500', max_servers=20, region=MSRegion.Wor
ms.close()
return

next_ip = f'{ip}:{port}'.encode('utf-8')
next_ip = f'{ip}:{port}'.encode()

ms.close()

Expand Down
2 changes: 1 addition & 1 deletion steam/guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def generate_device_id(steamid):
:rtype: str
"""
h = hexlify(sha1_hash(str(steamid).encode('ascii'))).decode('ascii')
return "android:{}-{}-{}-{}-{}".format(h[:8], h[8:12], h[12:16], h[16:20], h[20:32])
return f"android:{h[:8]}-{h[8:12]}-{h[12:16]}-{h[16:20]}-{h[20:32]}"

def extract_secrets_from_android_rooted(adb_path='adb'):
"""Extract Steam Authenticator secrets from a rooted Android device
Expand Down
4 changes: 2 additions & 2 deletions steam/utils/proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def proto_fill_from_dict(message, data, clear=True):
if desc.type == desc.TYPE_MESSAGE:
if desc.label == desc.LABEL_REPEATED:
if not isinstance(val, _list_types):
raise TypeError("Expected {} to be of type list, got {}".format(repr(key), type(val)))
raise TypeError(f"Expected {repr(key)} to be of type list, got {type(val)}")

list_ref = getattr(message, key)

Expand All @@ -93,7 +93,7 @@ def proto_fill_from_dict(message, data, clear=True):
proto_fill_from_dict(item_message, item)
else:
if not isinstance(val, dict):
raise TypeError("Expected {} to be of type dict, got {}".format(repr(key), type(dict)))
raise TypeError(f"Expected {repr(key)} to be of type dict, got {type(dict)}")

proto_fill_from_dict(getattr(message, key), val)
else:
Expand Down

0 comments on commit 29c5cbc

Please sign in to comment.