Skip to content

Commit

Permalink
ci: Upgrade pylint to support Python 3.12 (#1472)
Browse files Browse the repository at this point in the history
Also fixes issues raised by the newer, stricter pylint
  • Loading branch information
joeyparrish authored Jan 10, 2025
1 parent 8b52868 commit ea48ee4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
sudo install -m 755 git-clang-format /usr/local/bin/git-clang-format
rm git-clang-format
python3 -m pip install --upgrade pylint==2.8.3
python3 -m pip install --upgrade pylint==3.3.3
# NOTE: Must use base.sha instead of base.ref, since we don't have
# access to the branch name that base.ref would give us.
Expand Down
2 changes: 2 additions & 0 deletions packager/app/test/packager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ def tearDown(self):
shutil.rmtree(self.tmp_dir)
super().tearDown()

# pylint: disable=too-many-positional-arguments
def _GetStream(self,
descriptor,
language=None,
Expand Down Expand Up @@ -457,6 +458,7 @@ def _GetStreams(self, streams, test_files=None, **kwargs):

return out

# pylint: disable=too-many-positional-arguments
def _GetFlags(self,
strip_parameter_set_nalus=True,
encryption=False,
Expand Down
19 changes: 4 additions & 15 deletions packager/tools/git/pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ disable=abstract-method,
buffer-builtin,
c-extension-no-member,
consider-using-enumerate,
consider-using-f-string,
cmp-builtin,
cmp-method,
coerce-builtin,
Expand Down Expand Up @@ -155,12 +156,6 @@ disable=abstract-method,
# mypackage.mymodule.MyReporterClass.
output-format=text

# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]". This option is deprecated
# and it will be removed in Pylint 2.0.
files-output=no

# Tells whether to display a full report or only the messages
reports=no

Expand Down Expand Up @@ -279,12 +274,6 @@ ignore-long-lines=(?x)(
# else.
single-line-if-stmt=yes

# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=

# Maximum number of lines in a module
max-module-lines=99999

Expand Down Expand Up @@ -436,6 +425,6 @@ valid-metaclass-classmethod-first-arg=mcs

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=StandardError,
Exception,
BaseException
overgeneral-exceptions=builtins.StandardError,
builtins.Exception,
builtins.BaseException
27 changes: 14 additions & 13 deletions packager/tools/pssh/pssh-box.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def has_data(self):
def read_bytes(self, count):
"""Reads the given number of bytes into an array."""
if len(self.data) < self.position + count:
raise Exception('Invalid PSSH box, not enough data')
raise RuntimeError('Invalid PSSH box, not enough data')
ret = self.data[self.position:self.position+count]
self.position += count
return ret
Expand Down Expand Up @@ -211,7 +211,7 @@ def _parse_playready_data(data):
reader = BinaryReader(data, little_endian=True)
size = reader.read_int(4)
if size != len(data):
raise Exception('Length incorrect')
raise RuntimeError('Length incorrect')

ret = []
count = reader.read_int(2)
Expand All @@ -236,10 +236,10 @@ def _parse_playready_data(data):
' ' + base64.b64encode(record_data)
])
else:
raise Exception('Invalid record type %d' % record_type)
raise RuntimeError('Invalid record type %d' % record_type)

if reader.has_data():
raise Exception('Extra data after records')
raise RuntimeError('Extra data after records')

return ret

Expand All @@ -254,13 +254,13 @@ def _parse_boxes(data):

box_type = reader.read_bytes(4)
if box_type != b'pssh':
raise Exception(
raise RuntimeError(
'Invalid box type 0x%s, not \'pssh\'' % box_type.encode('hex'))

version_and_flags = reader.read_int(4)
version = version_and_flags >> 24
if version > 1:
raise Exception('Invalid PSSH version %d' % version)
raise RuntimeError('Invalid PSSH version %d' % version)

system_id = reader.read_bytes(16)

Expand All @@ -276,7 +276,7 @@ def _parse_boxes(data):
pssh_data = reader.read_bytes(pssh_data_size)

if start + size != reader.position:
raise Exception('Box size does not match size of data')
raise RuntimeError('Box size does not match size of data')

pssh = Pssh(version, system_id, key_ids, pssh_data)
boxes.append(pssh)
Expand Down Expand Up @@ -398,7 +398,7 @@ def main(all_args):

if ns.format:
if output_format:
raise Exception('Can only specify one of: --base64, --hex, --human')
raise RuntimeError('Can only specify one of: --base64, --hex, --human')
else:
output_format = ns.format

Expand All @@ -407,26 +407,27 @@ def main(all_args):

pssh_data = ns.pssh_data
if pssh_data and ns.content_id:
raise Exception('Cannot specify both --pssh-data and --content-id')
raise RuntimeError('Cannot specify both --pssh-data and --content-id')
if ns.protection_scheme:
if ns.system_id != WIDEVINE_SYSTEM_ID:
raise Exception(
raise RuntimeError(
'--protection-scheme only valid with Widevine system ID')
if ns.content_id:
if ns.system_id != WIDEVINE_SYSTEM_ID:
raise Exception('--content-id only valid with Widevine system ID')
raise RuntimeError('--content-id only valid with Widevine system ID')

# Ignore if we have no data.
if not pssh_data and not ns.key_id and not ns.system_id:
continue
if not ns.system_id:
raise Exception('System ID is required')
raise RuntimeError('System ID is required')
if ns.system_id == WIDEVINE_SYSTEM_ID:
# Always generate version 0 for Widevine for backward compatibility.
version = 0
if not pssh_data:
if not ns.key_id and not ns.content_id:
raise Exception('Widevine system needs key-id or content-id or both')
raise RuntimeError(
'Widevine system needs key-id or content-id or both')
pssh_data = _generate_widevine_data(ns.key_id, ns.content_id,
ns.provider, ns.protection_scheme)
else:
Expand Down

0 comments on commit ea48ee4

Please sign in to comment.