Skip to content

Commit fc65934

Browse files
authored
Updated pylintrc to version 3.2 (#4909)
1 parent eb4c7e9 commit fc65934

24 files changed

+102
-69
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=pybde,pycaes,pycreg,pyesedb,pyevt,pyevtx,pyewf,pyfcrypto,pyfsapfs,pyfsext,pyfsfat,pyfshfs,pyfsntfs,pyfsxfs,pyfvde,pyfwnt,pyfwsi,pylnk,pyluksde,pymodi,pymsiecf,pyolecf,pyphdi,pyqcow,pyregf,pyscca,pysigscan,pysmdev,pysmraw,pytsk3,pyvhdi,pyvmdk,pyvsapm,pyvsgpt,pyvshadow,pyvslvm,xattr,yara,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

plaso/analysis/hash_tagging.py

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ def _MakeRequestAndDecodeJSON(self, url, method, **kwargs):
106106
if method_upper not in ('GET', 'POST'):
107107
raise ValueError('Method {0:s} is not supported')
108108

109+
response = None
110+
109111
try:
110112
if method_upper == 'GET':
111113
response = requests.get(url, timeout=self._REQUEST_TIMEOUT, **kwargs)

plaso/cli/image_export_tool.py

+3
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ def _ExtractDataStream(
218218
if not destination_path.endswith(os.path.sep):
219219
destination_path = destination_path + os.path.sep
220220

221+
# TODO: refactor
222+
path = None
223+
221224
target_path = os.path.join(target_directory, target_filename)
222225
if target_path.startswith(destination_path):
223226
path = target_path[len(destination_path):]

plaso/cli/tool_options.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def ListAnalysisPlugins(self):
5353

5454
column_width = 10
5555
for name, _, _ in analysis_plugin_info:
56-
if len(name) > column_width:
57-
column_width = len(name)
56+
column_width = max(column_width, len(name))
5857

5958
table_view = views.ViewsFactory.GetTableView(
6059
self._views_format_type, column_names=['Name', 'Description'],

plaso/cli/tools.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,7 @@ def ListTimeZones(self):
334334
"""Lists the time zones."""
335335
max_length = 0
336336
for time_zone_name in pytz.all_timezones:
337-
if len(time_zone_name) > max_length:
338-
max_length = len(time_zone_name)
337+
max_length = max(max_length, len(time_zone_name))
339338

340339
utc_date_time = datetime.datetime.utcnow()
341340

plaso/cli/views.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,7 @@ def AddRow(self, values):
164164
"""
165165
super(CLITableView, self).AddRow(values)
166166

167-
value_length = len(values[0])
168-
if value_length > self._column_width:
169-
self._column_width = value_length
167+
self._column_width = max(self._column_width, len(values[0]))
170168

171169
def Write(self, output_writer):
172170
"""Writes the table to the output writer.

plaso/engine/extractors.py

+7-13
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,12 @@ def _ExtractPathSpecsFromDirectory(self, file_entry, depth=0):
391391
if sub_file_entry.IsDirectory():
392392
sub_directories.append(sub_file_entry)
393393

394-
for path_spec in self._ExtractPathSpecsFromFile(sub_file_entry):
395-
yield path_spec
394+
yield from self._ExtractPathSpecsFromFile(sub_file_entry)
396395

397396
for sub_file_entry in sub_directories:
398397
try:
399-
for path_spec in self._ExtractPathSpecsFromDirectory(
400-
sub_file_entry, depth=depth + 1):
401-
yield path_spec
398+
yield from self._ExtractPathSpecsFromDirectory(
399+
sub_file_entry, depth=depth + 1)
402400

403401
except (
404402
IOError, dfvfs_errors.AccessError, dfvfs_errors.BackEndError,
@@ -463,15 +461,12 @@ def _ExtractPathSpecsFromFileSystem(
463461
if find_specs:
464462
searcher = file_system_searcher.FileSystemSearcher(
465463
file_system, path_spec)
466-
for extracted_path_spec in searcher.Find(find_specs=find_specs):
467-
yield extracted_path_spec
464+
yield from searcher.Find(find_specs=find_specs)
468465

469466
elif recurse_file_system:
470467
file_entry = file_system.GetFileEntryByPathSpec(path_spec)
471468
if file_entry:
472-
for extracted_path_spec in self._ExtractPathSpecsFromDirectory(
473-
file_entry):
474-
yield extracted_path_spec
469+
yield from self._ExtractPathSpecsFromDirectory(file_entry)
475470

476471
else:
477472
yield path_spec
@@ -535,8 +530,7 @@ def ExtractPathSpecs(
535530
yield path_spec
536531

537532
else:
538-
for extracted_path_spec in self._ExtractPathSpecsFromFileSystem(
533+
yield from self._ExtractPathSpecsFromFileSystem(
539534
path_spec, find_specs=find_specs,
540535
recurse_file_system=recurse_file_system,
541-
resolver_context=resolver_context):
542-
yield extracted_path_spec
536+
resolver_context=resolver_context)

plaso/engine/processing_status.py

+1
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ def _UpdateProcessStatus(
340340
process_status.pid = pid
341341
process_status.status = status
342342

343+
# pylint: disable=consider-using-min-builtin
343344
if used_memory > 0:
344345
process_status.used_memory = used_memory
345346

plaso/engine/yaml_timeliner_file.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,4 @@ def ReadFromFile(self, path):
117117
TimelinerDefinition: a timeliner definition.
118118
"""
119119
with open(path, 'r', encoding='utf-8') as file_object:
120-
for yaml_definition in self._ReadFromFileObject(file_object):
121-
yield yaml_definition
120+
yield from self._ReadFromFileObject(file_object)

plaso/formatters/yaml_formatters_file.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ def _ReadFormatterDefinition(self, formatter_definition_values):
232232
'Invalid event formatter definition: {0:s} missing source.'.format(
233233
data_type))
234234

235+
formatter = None
236+
235237
if formatter_type == 'basic':
236238
formatter = interface.BasicEventFormatter(
237239
data_type=data_type, format_string=message,
@@ -286,5 +288,4 @@ def ReadFromFile(self, path):
286288
EventFormatter: an event formatter.
287289
"""
288290
with open(path, 'r', encoding='utf-8') as file_object:
289-
for yaml_definition in self._ReadFromFileObject(file_object):
290-
yield yaml_definition
291+
yield from self._ReadFromFileObject(file_object)

plaso/lib/bufferlib.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def Clear(self):
5555

5656
def Flush(self):
5757
"""Returns a generator for all items and clear the buffer."""
58-
for item in self:
59-
yield item
58+
yield from self
6059
self.Clear()
6160

6261
def GetCurrent(self):

plaso/multi_process/merge_helpers.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ def _GetAttributeContainers(self, task_storage_reader):
4343
AttributeContainer: attribute container.
4444
"""
4545
for container_type in self._CONTAINER_TYPES:
46-
for container in task_storage_reader.GetAttributeContainers(
47-
container_type):
48-
yield container
46+
yield from task_storage_reader.GetAttributeContainers(container_type)
4947

5048
self.fully_merged = True
5149

plaso/parsers/bsm.py

+4
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,14 @@ def _FormatInAddrExToken(self, token_data):
438438
dict[str, str]: token values.
439439
"""
440440
protocol = self._NETWORK_PROTOCOLS.get(token_data.net_type, 'UNKNOWN')
441+
441442
if token_data.net_type == 4:
442443
ip_address = self._FormatPackedIPv6Address(token_data.ip_address[:4])
443444
elif token_data.net_type == 16:
444445
ip_address = self._FormatPackedIPv6Address(token_data.ip_address)
446+
else:
447+
ip_address = None
448+
445449
return {
446450
'protocols': protocol,
447451
'net_type': token_data.net_type,

plaso/parsers/cookie_plugins/ganalytics.py

+16
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ def _ParseCookieData(
177177

178178
number_of_sessions = self._ParseIntegerValue(fields[5])
179179

180+
else:
181+
domain_hash = None
182+
number_of_sessions = None
183+
visitor_identifier = None
184+
180185
event_data = GoogleAnalyticsUtmaEventData()
181186
event_data.cookie_name = self.COOKIE_NAME
182187
event_data.domain_hash = domain_hash
@@ -245,6 +250,11 @@ def _ParseCookieData(
245250
else:
246251
date_time = self._ParsePosixTime(fields[3])
247252

253+
else:
254+
date_time = None
255+
domain_hash = None
256+
number_of_pages_viewed = None
257+
248258
event_data = GoogleAnalyticsUtmbEventData()
249259
event_data.cookie_name = self.COOKIE_NAME
250260
event_data.domain_hash = domain_hash
@@ -366,6 +376,12 @@ def _ParseCookieData(
366376
key, _, value = variable.partition('=')
367377
extra_attributes[key] = urlparse.unquote(value)
368378

379+
else:
380+
date_time = None
381+
domain_hash = None
382+
number_of_sessions = None
383+
number_of_sources = None
384+
369385
event_data = GoogleAnalyticsUtmzEventData()
370386
event_data.cookie_name = self.COOKIE_NAME
371387
event_data.domain_hash = domain_hash

plaso/parsers/esedb_plugins/srum.py

+2
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ def _ConvertValueBinaryDataToFloatingPointValue(self, value):
238238
floating_point_map = self._GetDataTypeMap('float32le')
239239
elif value_length == 8:
240240
floating_point_map = self._GetDataTypeMap('float64le')
241+
else:
242+
floating_point_map = None
241243

242244
try:
243245
return self._ReadStructureFromByteStream(value, 0, floating_point_map)

plaso/parsers/java_idx.py

+4
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def ParseFileObject(self, parser_mediator, file_object):
100100
section1_map = self._GetDataTypeMap('java_idx_603_section1')
101101
elif file_header.format_version == 605:
102102
section1_map = self._GetDataTypeMap('java_idx_605_section1')
103+
else:
104+
section1_map = None
103105

104106
try:
105107
section1, data_size = self._ReadStructureFromFileObject(
@@ -116,6 +118,8 @@ def ParseFileObject(self, parser_mediator, file_object):
116118
elif file_header.format_version in (603, 604, 605):
117119
file_offset = 128
118120
section2_map = self._GetDataTypeMap('java_idx_603_section2')
121+
else:
122+
section2_map = None
119123

120124
try:
121125
section2, data_size = self._ReadStructureFromFileObject(

plaso/parsers/plist_plugins/interface.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -803,9 +803,8 @@ def _RecurseKey(self, plist_item, depth=15, key_path=''):
803803

804804
elif isinstance(plist_item, (list, tuple)):
805805
for sub_plist_item in plist_item:
806-
for subkey_values in self._RecurseKey(
807-
sub_plist_item, depth=depth - 1, key_path=key_path):
808-
yield subkey_values
806+
yield from self._RecurseKey(
807+
sub_plist_item, depth=depth - 1, key_path=key_path)
809808

810809
elif hasattr(plist_item, 'items'):
811810
for subkey_name, value in plist_item.items():
@@ -818,10 +817,9 @@ def _RecurseKey(self, plist_item, depth=15, key_path=''):
818817

819818
for sub_plist_item in value:
820819
if isinstance(sub_plist_item, dict):
821-
subkey_path = '{0:s}/{1:s}'.format(key_path, subkey_name)
822-
for subkey_values in self._RecurseKey(
823-
sub_plist_item, depth=depth - 1, key_path=subkey_path):
824-
yield subkey_values
820+
subkey_path = '/'.join([key_path, subkey_name])
821+
yield from self._RecurseKey(
822+
sub_plist_item, depth=depth - 1, key_path=subkey_path)
825823

826824
# pylint: disable=arguments-differ
827825
@abc.abstractmethod

plaso/parsers/spotlight_storedb.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,9 @@ def _ReadMetadataAttributePageValues(
10971097
data_type_map = self._GetDataTypeMap(
10981098
'spotlight_store_db_property_value21')
10991099

1100+
else:
1101+
data_type_map = None
1102+
11001103
page_data_offset = 12
11011104
page_data_size = page_header.used_page_size - 20
11021105
page_value_index = 0
@@ -1242,12 +1245,11 @@ def _ReadMetadataAttributeStreamsMap(
12421245
stream_values = self._ReadStreamsMap(parent_file_entry, streams_map_number)
12431246

12441247
if streams_map_number == 1:
1245-
data_type_map = self._GetDataTypeMap(
1246-
'spotlight_metadata_attribute_type')
1247-
1248+
data_type_map = self._GetDataTypeMap('spotlight_metadata_attribute_type')
12481249
elif streams_map_number == 2:
1249-
data_type_map = self._GetDataTypeMap(
1250-
'spotlight_metadata_attribute_value')
1250+
data_type_map = self._GetDataTypeMap('spotlight_metadata_attribute_value')
1251+
else:
1252+
data_type_map = None
12511253

12521254
for index, stream_value in enumerate(stream_values):
12531255
if index == 0:

plaso/parsers/text_plugins/syslog.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,14 @@ def _ParseSshdMessageBody(self, body):
264264
key = keys[0]
265265
structure = structure[0]
266266

267-
if key not in ('failed_connection', 'login', 'opened_connection'):
268-
return None
269-
270267
if key == 'failed_connection':
271268
event_data = SyslogSSHFailedConnectionEventData()
272269
elif key == 'login':
273270
event_data = SyslogSSHLoginEventData()
274271
elif key == 'opened_connection':
275272
event_data = SyslogSSHOpenedConnectionEventData()
273+
else:
274+
return None
276275

277276
event_data.authentication_method = structure.get(
278277
'authentication_method', None)

plaso/parsers/windefender_history.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ def _ReadThreatTrackingData(self, threat_tracking_data, file_offset):
121121
else:
122122
header = self._ReadThreatTrackingHeader(threat_tracking_data)
123123

124-
values_data_offset = header.header_size + 4
125-
values_data_end_offset = header.total_data_size
124+
values_data_offset = header.header_size + 4
125+
values_data_end_offset = header.total_data_size
126126

127127
while values_data_offset < values_data_end_offset:
128128
threat_value, data_size = self._ReadThreatTrackingValue(

0 commit comments

Comments
 (0)