3131Parameters files are fetched from autotest using requests
3232
3333"""
34+ from __future__ import annotations
3435
3536import argparse
3637import errno
4950import time
5051from concurrent .futures import ThreadPoolExecutor
5152from datetime import datetime
52- from typing import Dict , List , Optional
5353from urllib .parse import urlparse
5454
5555import requests
5858import rst_table
5959from frontend .scripts import get_discourse_posts
6060
61- if sys .version_info < (3 , 8 ):
61+ if sys .version_info < (3 , 8 ): # noqa: UP036
6262 print ("Minimum python version is 3.8" )
6363 sys .exit (1 )
6464
@@ -149,7 +149,7 @@ def fetch_and_rename(fetchurl: str, target_file: str, new_name: str) -> None:
149149 os .replace (new_name , target_file )
150150
151151
152- def fetch_url (fetchurl : str , fpath : Optional [ str ] = None , verbose : bool = True ) -> None :
152+ def fetch_url (fetchurl : str , fpath : str | None = None , verbose : bool = True ) -> None :
153153 """Fetches content at url and puts it in a file corresponding to the filename in the URL"""
154154 progress (f"Fetching { fetchurl } " )
155155
@@ -192,7 +192,7 @@ def get_request_file_size(url: str) -> int:
192192 return 0
193193
194194
195- def fetchparameters (site : Optional [ str ] = None , cache : Optional [ str ] = None ) -> None :
195+ def fetchparameters (site : str | None = None , cache : str | None = None ) -> None :
196196 dataname = "Parameters"
197197 fetch_ardupilot_generated_data (
198198 PARAMETER_SITE ,
@@ -204,7 +204,7 @@ def fetchparameters(site: Optional[str] = None, cache: Optional[str] = None) ->
204204 )
205205
206206
207- def fetchlogmessages (site : Optional [ str ] = None , cache : Optional [ str ] = None ) -> None :
207+ def fetchlogmessages (site : str | None = None , cache : str | None = None ) -> None :
208208 dataname = "LogMessages"
209209 fetch_ardupilot_generated_data (
210210 LOGMESSAGE_SITE ,
@@ -216,18 +216,18 @@ def fetchlogmessages(site: Optional[str] = None, cache: Optional[str] = None) ->
216216 )
217217
218218
219- def fetch_ardupilot_generated_data (site_mapping : Dict , base_url : str , sub_url : str , document_name : str ,
220- site : Optional [ str ] = None , cache : Optional [ str ] = None ) -> None :
219+ def fetch_ardupilot_generated_data (site_mapping : dict , base_url : str , sub_url : str , document_name : str ,
220+ site : str | None = None , cache : str | None = None ) -> None :
221221 """Fetches the data for all the sites from the test server and
222222 copies them to the correct location.
223223
224224 This is always run as part of a build (i.e. no checking to see if
225225 parameters or logmessage have changed.)
226226
227227 """
228- urls : List [str ] = []
229- targetfiles : List [str ] = []
230- names : List [str ] = []
228+ urls : list [str ] = []
229+ targetfiles : list [str ] = []
230+ names : list [str ] = []
231231
232232 for key , value in site_mapping .items ():
233233 fetchurl = f'{ base_url } /{ value } /{ sub_url } '
@@ -444,7 +444,7 @@ def copy_common_source_files(start_dir=COMMON_DIR, clean_common=False):
444444 for file in files :
445445 if file .endswith (".rst" ):
446446 source_file_path = os .path .join (root , file )
447- with open (source_file_path , 'r' , encoding = 'utf-8' ) as f :
447+ with open (source_file_path , encoding = 'utf-8' ) as f :
448448 source_content = f .read ()
449449 targets = get_copy_targets (source_content )
450450 for wiki in targets :
@@ -478,7 +478,7 @@ def copy_common_source_files(start_dir=COMMON_DIR, clean_common=False):
478478 if file .endswith (".rst" ):
479479 # debug(" FILE: %s" % file)
480480 source_file_path = os .path .join (root , file )
481- source_file = open (source_file_path , 'r' , encoding = 'utf-8' )
481+ source_file = open (source_file_path , encoding = 'utf-8' )
482482 source_content = source_file .read ()
483483 source_file .close ()
484484 targets = get_copy_targets (source_content )
@@ -511,7 +511,7 @@ def copy_common_source_files(start_dir=COMMON_DIR, clean_common=False):
511511 shutil .copy2 (src , dst )
512512 elif file .endswith (".js" ):
513513 source_file_path = os .path .join (root , file )
514- source_file = open (source_file_path , 'r' , encoding = 'utf-8' )
514+ source_file = open (source_file_path , encoding = 'utf-8' )
515515 source_content = source_file .read ()
516516 source_file .close ()
517517 targets = get_copy_targets (source_content )
@@ -842,7 +842,7 @@ def check_ref_directives():
842842 wiki_glob = set (glob .glob ("**/*.rst" , recursive = True ))
843843 files_to_check = wiki_glob .difference (skipped_files )
844844 for f in files_to_check :
845- with open (f , "r" , encoding = 'utf-8' ) as file :
845+ with open (f , encoding = 'utf-8' ) as file :
846846 try :
847847 for i , line in enumerate (file .readlines ()):
848848 if character_before_ref_tag .search (line ):
0 commit comments