From 037e0d3fdc4aef79db87909a3f4dba7b6467b500 Mon Sep 17 00:00:00 2001 From: Miro Date: Thu, 21 May 2026 20:25:11 +0200 Subject: [PATCH] Fix SteamID regex syntax warnings --- steam/steamid.py | 4 ++-- tests/test_steamid.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/steam/steamid.py b/steam/steamid.py index 3d93ab66..26414fff 100644 --- a/steam/steamid.py +++ b/steam/steamid.py @@ -501,7 +501,7 @@ def from_csgo_friend_code(code, universe=EUniverse.Public): :return: SteamID instance :rtype: :class:`.SteamID` or :class:`None` """ - if not re.match(r'^['+_csgofrcode_chars+'\-]{10}$', code): + if not re.match(r'^['+_csgofrcode_chars+r'\-]{10}$', code): return None code = ('AAAA-' + code).replace('-', '') @@ -574,7 +574,7 @@ def steam64_from_url(url, http_timeout=30): # group profiles else: text = web.get(match.group('clean_url'), timeout=http_timeout).text - data_match = re.search("OpenGroupChat\( *'(?P\d+)'", text) + data_match = re.search(r"OpenGroupChat\( *'(?P\d+)'", text) if data_match: return int(data_match.group('steamid')) diff --git a/tests/test_steamid.py b/tests/test_steamid.py index 269a2cf7..14a8965d 100644 --- a/tests/test_steamid.py +++ b/tests/test_steamid.py @@ -337,6 +337,16 @@ def test_steam64_from_url_timeout(self, mrs_mock): mm.get.side_effect = requests.exceptions.ReadTimeout('test') self.assertIsNone(steamid.steam64_from_url("https://steamcommunity.com/id/timeout_me")) + @mock.patch('steam.steamid.make_requests_session') + def test_steam64_from_url_group_chat_markup(self, mrs_mock): + mm = mrs_mock.return_value = mock.MagicMock() + mm.get.return_value.text = "OpenGroupChat( '103582791429521412'" + + self.assertEqual( + steamid.steam64_from_url("https://steamcommunity.com/groups/Valve"), + 103582791429521412 + ) + def test_steam64_from_url(self): def scrub_req(r): r.headers.pop('Cookie', None)