diff --git a/.github/workflows/testing_initiative.yml b/.github/workflows/testing_initiative.yml index a5f20006..df08e2cd 100644 --- a/.github/workflows/testing_initiative.yml +++ b/.github/workflows/testing_initiative.yml @@ -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 diff --git a/dev_requirements.txt b/dev_requirements.txt index a5b94e85..404214be 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -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 diff --git a/generate_enums_from_proto.py b/generate_enums_from_proto.py index 375ee722..750c655f 100644 --- a/generate_enums_from_proto.py +++ b/generate_enums_from_proto.py @@ -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):") diff --git a/requirements.txt b/requirements.txt index 8a00aa95..b5ec7b6f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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/vdf.git@v4.0 +cachetools>=3.0.0 + gevent>=1.3.0 protobuf~=3.0 gevent-eventemitter~=2.1 -cachetools>=3.0.0 diff --git a/setup.py b/setup.py index 766100cc..af3fdbaa 100644 --- a/setup.py +++ b/setup.py @@ -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/vdf.git@v4.0', 'cachetools>=3.0.0', ] @@ -38,20 +38,19 @@ author="Rossen Georgiev / Solstice Game Studios", author_email='py-steam@solsticegamestudios.com', 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', diff --git a/steam/client/cdn.py b/steam/client/cdn.py index 9c6bd9da..da2f4776 100644 --- a/steam/client/cdn.py +++ b/steam/client/cdn.py @@ -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) @@ -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)) @@ -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 @@ -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) @@ -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 diff --git a/steam/core/cm.py b/steam/core/cm.py index 72e355da..7eb5b50b 100644 --- a/steam/core/cm.py +++ b/steam/core/cm.py @@ -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)) @@ -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)) diff --git a/steam/core/msg/__init__.py b/steam/core/msg/__init__.py index 3a9642ed..5f72623f 100644 --- a/steam/core/msg/__init__.py +++ b/steam/core/msg/__init__.py @@ -150,7 +150,7 @@ def __repr__(self): else: suffix = 'n/a' - return "".format(self.msg, suffix) + return f"" def __str__(self): rows = [repr(self)] @@ -238,7 +238,7 @@ def __repr__(self): else: suffix = 'n/a' - return "".format(self.msg, suffix) + return f"" def __str__(self): rows = [repr(self)] diff --git a/steam/exceptions.py b/steam/exceptions.py index 90a494c8..fe06b9b6 100644 --- a/steam/exceptions.py +++ b/steam/exceptions.py @@ -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): """ diff --git a/steam/game_servers.py b/steam/game_servers.py index a141180d..8ca735cf 100644 --- a/steam/game_servers.py +++ b/steam/game_servers.py @@ -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() diff --git a/steam/guard.py b/steam/guard.py index 15c9e5dc..3529637f 100644 --- a/steam/guard.py +++ b/steam/guard.py @@ -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 diff --git a/steam/utils/proto.py b/steam/utils/proto.py index 8b7e491e..6a1598c0 100644 --- a/steam/utils/proto.py +++ b/steam/utils/proto.py @@ -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) @@ -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: