Ruff config (#2)

This commit is contained in:
Kacper Rączy
2023-12-06 15:39:21 -08:00
committed by GitHub
parent 8ec4778685
commit 4df237c512
4 changed files with 19 additions and 11 deletions

View File

@@ -31,3 +31,11 @@ dev = [
[project.urls]
"Homepage" = "https://github.com/commaai/teleoprtc"
"Bug Tracker" = "https://github.com/commaai/teleoprtc/issues"
# https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml
[tool.ruff]
select = ["E", "F", "W", "PIE", "C4", "ISC", "RUF008", "RUF100", "A", "B", "TID251"]
ignore = ["W292", "E741", "E402", "C408", "ISC003", "B027", "B024"]
line-length = 160
target-version="py311"
flake8-implicit-str-concat.allow-multiline=false

View File

@@ -68,7 +68,7 @@ class TestStreamIntegration(unittest.IsolatedAsyncioTestCase):
channel = stream.get_messaging_channel()
self.assertIsNotNone(channel)
self.assertEqual(channel.readyState, "open")
self.assertEqual(stream.has_incoming_audio_track(), recv_audio)
if stream.has_incoming_audio_track():
track = stream.get_incoming_audio_track(False)
@@ -103,4 +103,4 @@ class TestStreamIntegration(unittest.IsolatedAsyncioTestCase):
if __name__ == '__main__':
unittest.main()
unittest.main()

View File

@@ -18,13 +18,13 @@ class OfferCapture:
self.offer = offer
raise Exception("Offer captured")
class DummyH264VideoStreamTrack(TiciVideoStreamTrack):
kind = "video"
async def recv(self):
raise NotImplementedError()
def codec_preference(self):
return "H264"
@@ -40,7 +40,7 @@ class TestOfferStream(unittest.IsolatedAsyncioTestCase):
_ = await stream.start()
except Exception:
pass
info = parse_info_from_offer(capture.offer.sdp)
self.assertTrue(info.expected_audio_track)
self.assertFalse(info.incoming_audio_track)
@@ -55,7 +55,7 @@ class TestOfferStream(unittest.IsolatedAsyncioTestCase):
_ = await stream.start()
except Exception:
pass
info = parse_info_from_offer(capture.offer.sdp)
self.assertFalse(info.expected_audio_track)
self.assertTrue(info.incoming_audio_track)
@@ -70,11 +70,11 @@ class TestOfferStream(unittest.IsolatedAsyncioTestCase):
_ = await stream.start()
except Exception:
pass
info = parse_info_from_offer(capture.offer.sdp)
self.assertTrue(info.incoming_datachannel)
class TestAnswerStream(unittest.IsolatedAsyncioTestCase):
async def test_codec_preference(self):
offer_sdp = """v=0
@@ -142,12 +142,12 @@ a=ice-ufrag:1234
a=ice-pwd:1234
a=fingerprint:sha-256 15:F3:F0:23:67:44:EE:2C:AA:8C:D9:50:95:26:42:7C:67:EA:1F:D2:92:C5:97:01:7B:2E:57:C9:A3:13:00:4A
a=setup:actpass"""
builder = WebRTCAnswerBuilder(offer_sdp)
builder.add_video_stream("road", DummyH264VideoStreamTrack("road", 0.05))
stream = builder.stream()
with self.assertRaises(Exception):
with self.assertRaises(ValueError):
_ = await stream.start()

View File

@@ -23,7 +23,7 @@ class TestTracks(unittest.TestCase):
class VideoStream(TiciVideoStreamTrack):
async def recv(self):
raise NotImplementedError()
track = VideoStream("driver", 0.1)
camera_type, _ = parse_video_track_id(track.id)
self.assertEqual("driver", camera_type)