mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-11-11 11:30:39 +00:00
Explicitly open files as 'r' instead of leaving it out
This commit is contained in:
@@ -90,7 +90,7 @@ def parse_errors(json_file, descriptions_file):
|
||||
|
||||
The method yields `Error` instances as a result.
|
||||
"""
|
||||
with open(json_file, encoding='utf-8') as f:
|
||||
with open(json_file, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
|
||||
errors = defaultdict(set)
|
||||
@@ -124,7 +124,7 @@ def parse_errors(json_file, descriptions_file):
|
||||
# Prefer the descriptions that are related with Telethon way of coding
|
||||
# to those that PWRTelegram's API provides.
|
||||
telethon_descriptions = {}
|
||||
with open(descriptions_file, encoding='utf-8') as f:
|
||||
with open(descriptions_file, 'r', encoding='utf-8') as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#'):
|
||||
|
||||
@@ -278,7 +278,7 @@ def parse_tl(file_path, layer, invalid_bot_methods=None):
|
||||
if invalid_bot_methods is None:
|
||||
invalid_bot_methods = set()
|
||||
|
||||
with open(file_path, encoding='utf-8') as file:
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
is_function = False
|
||||
for line in file:
|
||||
comment_index = line.find('//')
|
||||
@@ -307,7 +307,7 @@ def parse_tl(file_path, layer, invalid_bot_methods=None):
|
||||
def find_layer(file_path):
|
||||
"""Finds the layer used on the specified scheme.tl file."""
|
||||
layer_regex = re.compile(r'^//\s*LAYER\s*(\d+)$')
|
||||
with open(file_path, encoding='utf-8') as file:
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
for line in file:
|
||||
match = layer_regex.match(line)
|
||||
if match:
|
||||
|
||||
Reference in New Issue
Block a user