Skip to content

Commit 97cdadb

Browse files
committed
Updated pylintrc to version 3.2
1 parent 50a2e5d commit 97cdadb

16 files changed

+79
-51
lines changed

.pylintrc

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Pylint 3.0.x configuration file
1+
# Pylint 3.2.x configuration file
22
#
33
# This file is generated by l2tdevtools update-dependencies.py, any dependency
44
# related changes should be made in dependencies.ini.
@@ -29,6 +29,7 @@ clear-cache-post-run=no
2929
# A comma-separated list of package or module names from where C extensions may
3030
# be loaded. Extensions are loading into the active Python interpreter and may
3131
# run arbitrary code.
32+
# extension-pkg-allow-list=
3233
extension-pkg-allow-list=pyfwps,pyfwsi,pygzipf,pylnk,pyolecf,pyregf,zstd
3334

3435
# A comma-separated list of package or module names from where C extensions may
@@ -63,10 +64,11 @@ ignore-paths=
6364
# Emacs file locks
6465
ignore-patterns=^\.#
6566

66-
# List of module names for which member attributes should not be checked
67-
# (useful for modules/projects where namespaces are manipulated during runtime
68-
# and thus existing member attributes cannot be deduced by static analysis). It
69-
# supports qualified module names, as well as Unix pattern matching.
67+
# List of module names for which member attributes should not be checked and
68+
# will not be imported (useful for modules/projects where namespaces are
69+
# manipulated during runtime and thus existing member attributes cannot be
70+
# deduced by static analysis). It supports qualified module names, as well as
71+
# Unix pattern matching.
7072
ignored-modules=
7173

7274
# Python code to execute, usually for sys.path manipulation such as
@@ -85,11 +87,16 @@ limit-inference-results=100
8587

8688
# List of plugins (as comma separated values of python module names) to load,
8789
# usually to register additional checkers.
90+
# load-plugins=
8891
load-plugins=pylint.extensions.docparams
8992

9093
# Pickle collected data for later comparisons.
9194
persistent=yes
9295

96+
# Resolve imports to .pyi stubs if available. May reduce no-member messages and
97+
# increase not-an-iterable messages.
98+
prefer-stubs=no
99+
93100
# Minimum Python version to use for version dependent checks. Will default to
94101
# the version used to run pylint.
95102
py-version=3.12
@@ -440,7 +447,6 @@ confidence=HIGH,
440447
# --enable=similarities". If you want to run only the classes checker, but have
441448
# no Warning level messages displayed, use "--disable=all --enable=classes
442449
# --disable=W".
443-
444450
disable=assignment-from-none,
445451
bad-inline-option,
446452
consider-using-f-string,
@@ -478,6 +484,7 @@ disable=assignment-from-none,
478484
# either give multiple identifier separated by comma (,) or put this option
479485
# multiple time (only on the command line, not in the configuration file where
480486
# it should appear only once). See also the "--disable" option for examples.
487+
# enable=
481488
enable=c-extension-no-member
482489

483490

@@ -510,6 +517,11 @@ max-nested-blocks=5
510517
# printed.
511518
never-returning-functions=sys.exit,argparse.parse_error
512519

520+
# Let 'consider-using-join' be raised when the separator to join on would be
521+
# non-empty (resulting in expected fixes of the type: ``"- " + " -
522+
# ".join(items)``)
523+
suggest-join-with-non-empty-separator=yes
524+
513525

514526
[REPORTS]
515527

dtformats/chrome_cache.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -739,10 +739,6 @@ def ParseFile(self, path):
739739
raise errors.ParseError(
740740
f'Unable to signature with error: {exception!s}')
741741

742-
if signature not in (DataBlockFile.SIGNATURE, IndexFile.SIGNATURE):
743-
raise errors.ParseError(
744-
f'Unsupported signature: 0x{signature:08x}')
745-
746742
if signature == DataBlockFile.SIGNATURE:
747743
chrome_cache_file = DataBlockFile(
748744
debug=self._debug, output_writer=self._output_writer)
@@ -751,4 +747,7 @@ def ParseFile(self, path):
751747
chrome_cache_file = IndexFile(
752748
debug=self._debug, output_writer=self._output_writer)
753749

750+
else:
751+
raise errors.ParseError(f'Unsupported signature: 0x{signature:08x}')
752+
754753
chrome_cache_file.ReadFileObject(file_object)

dtformats/cpio.py

+2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ def _ReadFileEntry(self, file_object, file_offset):
169169
data_type_map = self._GetDataTypeMap('cpio_portable_ascii_file_entry')
170170
elif self.file_format in ('crc', 'newc'):
171171
data_type_map = self._GetDataTypeMap('cpio_new_ascii_file_entry')
172+
else:
173+
data_type_map = None
172174

173175
file_entry, file_entry_data_size = self._ReadStructureFromFileObject(
174176
file_object, file_offset, data_type_map, 'file entry')

dtformats/fseventsd.py

+2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def _ReadDLSRecord(self, file_object, file_offset, format_version):
8080
data_type_map = self._GetDataTypeMap('dls_record_v1')
8181
elif format_version == 2:
8282
data_type_map = self._GetDataTypeMap('dls_record_v2')
83+
else:
84+
data_type_map = None
8385

8486
dls_record, bytes_read = self._ReadStructureFromFileObject(
8587
file_object, file_offset, data_type_map, 'DLS record')

dtformats/jump_list.py

+4
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ def _ReadDestListEntry(self, olecf_item, stream_offset):
135135
data_type_map = self._GetDataTypeMap('dest_list_entry_v2')
136136
description = 'dest list entry v2'
137137

138+
else:
139+
data_type_map = None
140+
description = None
141+
138142
dest_list_entry, entry_data_size = self._ReadStructureFromFileObject(
139143
olecf_item, stream_offset, data_type_map, description)
140144

dtformats/spotlight_storedb.py

+6
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,9 @@ def _ReadMetadataAttributePageValues(
11741174
Raises:
11751175
ParseError: if the property page values cannot be read.
11761176
"""
1177+
data_type_map = None
1178+
debug_info = None
1179+
11771180
if page_header.property_table_type == 0x00000011:
11781181
data_type_map = self._GetDataTypeMap(
11791182
'spotlight_store_db_property_value11')
@@ -1277,6 +1280,9 @@ def _ReadMetadataAttributeStreamsMap(
12771280
"""
12781281
stream_values = self._ReadStreamsMap(streams_map_number)
12791282

1283+
data_type_map = None
1284+
debug_info = None
1285+
12801286
if streams_map_number == 1:
12811287
data_type_map = self._GetDataTypeMap(
12821288
'spotlight_metadata_attribute_type')

dtformats/usn_journal.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ def ReadRecords(self):
6767

6868
file_offset = 0
6969
while file_offset < self._file_size:
70-
block_size = 4096
71-
if block_size > self._file_size:
72-
block_size = self._file_size
70+
block_size = min(4096, self._file_size)
7371

7472
while block_size > 60:
7573
usn_record_header = self._file_object.read(60)

dtformats/wmi_repository.py

+20-34
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ def _ReadChildObjectsTree(self, file_object, root_node_offset):
12101210
leaf_node = self._ReadChildObjectsTreeLeafNode(
12111211
node_cell.data, branch_node.leaf_node_offset)
12121212

1213-
for node_offset in (
1213+
yield from (
12141214
leaf_node.value_node_offset1,
12151215
leaf_node.value_node_offset2,
12161216
leaf_node.value_node_offset3,
@@ -1220,8 +1220,7 @@ def _ReadChildObjectsTree(self, file_object, root_node_offset):
12201220
leaf_node.value_node_offset7,
12211221
leaf_node.value_node_offset8,
12221222
leaf_node.value_node_offset9,
1223-
leaf_node.value_node_offset10):
1224-
yield node_offset
1223+
leaf_node.value_node_offset10)
12251224

12261225
# TODO: rename
12271226
def _ReadChildObjectsTreeBranchNode(self, block_data, file_offset):
@@ -1770,9 +1769,8 @@ def _ReadClassDefinitionHierarchy(self, file_object, root_node_offset):
17701769
for value_node_offset in self._ReadChildObjectsTree(
17711770
file_object, root_node.sub_node_offset):
17721771
if value_node_offset > 40:
1773-
for instance in self._ReadClassDefinitionHierarchy(
1774-
file_object, value_node_offset):
1775-
yield instance
1772+
yield from self._ReadClassDefinitionHierarchy(
1773+
file_object, value_node_offset)
17761774

17771775
if self._debug:
17781776
if root_node.child_objects_root_node_offset > 40:
@@ -1900,10 +1898,8 @@ def _ReadInstanceHierarchy(self, file_object, root_node_offset):
19001898
node_cell.data, instance_leaf_value_node.name_node_offset)
19011899

19021900
if instance_leaf_value_node.instance_root_node_offset > 40:
1903-
for instance in self._ReadInstanceHierarchy(
1904-
file_object,
1905-
instance_leaf_value_node.instance_root_node_offset):
1906-
yield instance
1901+
yield from self._ReadInstanceHierarchy(
1902+
file_object, instance_leaf_value_node.instance_root_node_offset)
19071903

19081904
if self._debug:
19091905
if root_node.child_objects_list_node_offset > 40:
@@ -1956,11 +1952,10 @@ def _ReadNamespaceInstanceHierarchy(
19561952
node_cell.data, value_node_offset)
19571953

19581954
if instance_leaf_value_node.instance_root_node_offset > 40:
1959-
for instance in self._ReadNamespaceInstanceHierarchy(
1955+
yield from self._ReadNamespaceInstanceHierarchy(
19601956
file_object,
19611957
instance_leaf_value_node.instance_root_node_offset,
1962-
namespace_segments):
1963-
yield instance
1958+
namespace_segments)
19641959

19651960
def ReadClassDefinitions(self):
19661961
"""Reads class definitions.
@@ -1969,9 +1964,8 @@ def ReadClassDefinitions(self):
19691964
Instance: instance.
19701965
"""
19711966
if self._system_class_definition_root_node_offset > 40:
1972-
for instance in self._ReadClassDefinitionHierarchy(
1973-
self._file_object, self._system_class_definition_root_node_offset):
1974-
yield instance
1967+
yield from self._ReadClassDefinitionHierarchy(
1968+
self._file_object, self._system_class_definition_root_node_offset)
19751969

19761970
def ReadInstances(self):
19771971
"""Reads instances.
@@ -1980,9 +1974,8 @@ def ReadInstances(self):
19801974
Instance: instance.
19811975
"""
19821976
if self._root_namespace_node_offset > 40:
1983-
for instance in self._ReadInstanceHierarchy(
1984-
self._file_object, self._root_namespace_node_offset):
1985-
yield instance
1977+
yield from self._ReadInstanceHierarchy(
1978+
self._file_object, self._root_namespace_node_offset)
19861979

19871980
def ReadNamespaces(self):
19881981
"""Reads namespace instances.
@@ -1991,9 +1984,8 @@ def ReadNamespaces(self):
19911984
Instance: instance.
19921985
"""
19931986
if self._root_namespace_node_offset > 40:
1994-
for instance in self._ReadNamespaceInstanceHierarchy(
1995-
self._file_object, self._root_namespace_node_offset, []):
1996-
yield instance
1987+
yield from self._ReadNamespaceInstanceHierarchy(
1988+
self._file_object, self._root_namespace_node_offset, [])
19971989

19981990
def ReadFileObject(self, file_object):
19991991
"""Reads a mappings file-like object.
@@ -3462,14 +3454,12 @@ def _GetKeysFromIndexPage(self, index_page):
34623454
str: a CIM key.
34633455
"""
34643456
if index_page:
3465-
for key in index_page.keys:
3466-
yield key
3457+
yield from index_page.keys
34673458

34683459
for mapped_page_number in index_page.sub_pages:
34693460
sub_index_page = self._GetIndexPageByMappedPageNumber(
34703461
mapped_page_number)
3471-
for key in self._GetKeysFromIndexPage(sub_index_page):
3472-
yield key
3462+
yield from self._GetKeysFromIndexPage(sub_index_page)
34733463

34743464
def _GetObjectsPageByMappedPageNumber(self, mapped_page_number, is_data_page):
34753465
"""Retrieves a specific objects page by mapped page number.
@@ -3942,8 +3932,7 @@ def GetInstances(self):
39423932
Instance: an instance.
39433933
"""
39443934
if self._repository_file:
3945-
for instance in self._repository_file.ReadInstances():
3946-
yield instance
3935+
yield from self._repository_file.ReadInstances()
39473936

39483937
else:
39493938
for _, object_record in self._ReadInstanceObjectRecords():
@@ -3962,15 +3951,13 @@ def GetNamespaces(self):
39623951
Instance: an instance.
39633952
"""
39643953
if self._repository_file:
3965-
for instance in self._repository_file.ReadNamespaces():
3966-
yield instance
3954+
yield from self._repository_file.ReadNamespaces()
39673955

39683956
else:
39693957
if not self._namespace_instances:
39703958
self._ReadNamespacesFromObjectRecords()
39713959

3972-
for instance in self._namespace_instances:
3973-
yield instance
3960+
yield from self._namespace_instances
39743961

39753962
def GetIndexKeys(self):
39763963
"""Retrieves the index keys.
@@ -3980,8 +3967,7 @@ def GetIndexKeys(self):
39803967
"""
39813968
if self._index_binary_tree_file:
39823969
index_page = self._GetIndexRootPage()
3983-
for key in self._GetKeysFromIndexPage(index_page):
3984-
yield key
3970+
yield from self._GetKeysFromIndexPage(index_page)
39853971

39863972
# TODO: remove after debugging.
39873973
def GetObjectRecordByKey(self, key):

dtformats/yaml_definitions_file.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,4 @@ def ReadFromFile(self, path):
174174
DebugDefinition: a debug definition.
175175
"""
176176
with open(path, 'r', encoding='utf-8') as file_object:
177-
for yaml_definition in self._ReadFromFileObject(file_object):
178-
yield yaml_definition
177+
yield from self._ReadFromFileObject(file_object)

scripts/cpio.py

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ def HashFileEntries(self):
8686
f'Unsupported file type at offset: 0x{file_offset:08x}.\n')
8787
return
8888

89+
cpio_file_object = None
90+
8991
if file_type == 'cpio':
9092
file_object.seek(file_offset, os.SEEK_SET)
9193
cpio_file_object = file_object

scripts/firefox_cache1.py

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def Main():
5656
elif filename.startswith('_CACHE_00'):
5757
cache_file = firefox_cache1.CacheBlockFile(
5858
debug=options.debug, output_writer=output_writer)
59+
else:
60+
print('Unsupported Firefox cache version 1 file name.')
61+
print('')
62+
return False
5963

6064
cache_file.Open(options.source)
6165

scripts/indexeddb.py

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def Main():
7979
value_type_string = 'del'
8080
elif table_entry.value_type == 1:
8181
value_type_string = 'val'
82+
else:
83+
value_type_string = 'UNKNOWN'
8284

8385
key = ', '.join(table_entry.key_segments)
8486

scripts/leveldb.py

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ def Main():
104104
value_type_string = 'del'
105105
elif table_entry.value_type == 1:
106106
value_type_string = 'val'
107+
else:
108+
value_type_string = 'UNKNOWN'
107109

108110
# Print key and value without leading b
109111
key = repr(table_entry.key)[1:]

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = dtformats
3-
version = 20241006
3+
version = 20241007
44
description = Data formats (dtformats)
55
long_description = dtFormats is a collection of various file formats.
66
long_description_content_type = text/plain

tests/test_lib.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
"""Shared test case."""
33

4+
import abc
45
import os
56
import unittest
67

@@ -70,3 +71,12 @@ def WriteText(self, text):
7071
text (str): text to write.
7172
"""
7273
self.output.append(text)
74+
75+
@abc.abstractmethod
76+
def WriteValue(self, description, value):
77+
"""Writes a value.
78+
79+
Args:
80+
description (str): description.
81+
value (str): value to write.
82+
"""

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ deps =
4545
-rrequirements.txt
4646
-rtest_requirements.txt
4747
docformatter
48-
pylint >= 3.0.0, < 3.1.0
48+
pylint >= 3.2.0, < 3.3.0
4949
setuptools
5050
yamllint >= 1.26.0
5151
commands =

0 commit comments

Comments
 (0)