2121import parse
2222
2323import github as pygithub
24- from adabot import github_requests as gh_reqs
24+ from adabot import github_requests as gh_reqs , REQUESTS_TIMEOUT
2525from adabot .lib import common_funcs
2626from adabot .lib import assign_hacktober_label as hacktober
2727
@@ -231,7 +231,7 @@ def rtd_yml_base(self):
231231 "%20if%20cookiecutter.sphinx_docs%20in%20%5B'y'%2C%20'yes'%5D%20%25"
232232 "%7D.readthedocs.yaml%7B%25%20endif%20%25%7D"
233233 )
234- rtd_yml = requests .get (rtd_yml_dl_url )
234+ rtd_yml = requests .get (rtd_yml_dl_url , timeout = REQUESTS_TIMEOUT )
235235 if rtd_yml .ok :
236236 try :
237237 self ._rtd_yaml_base = yaml .safe_load (rtd_yml .text )
@@ -255,7 +255,7 @@ def pcc_versions(self):
255255 "circuitpython/main/%7B%7B%20cookiecutter.__dirname%20%7D%7D/.pre-"
256256 "commit-config.yaml"
257257 )
258- pcc_yml = requests .get (pcc_yml_dl_url )
258+ pcc_yml = requests .get (pcc_yml_dl_url , timeout = REQUESTS_TIMEOUT )
259259 if pcc_yml .ok :
260260 try :
261261 pcc_yaml_base = yaml .safe_load (pcc_yml .text )
@@ -463,7 +463,7 @@ def _filter_file_diffs(filenames):
463463 def _validate_readme (self , download_url ):
464464 # We use requests because file contents are hosted by
465465 # githubusercontent.com, not the API domain.
466- contents = requests .get (download_url , timeout = 30 )
466+ contents = requests .get (download_url , timeout = REQUESTS_TIMEOUT )
467467 if not contents .ok :
468468 return [ERROR_README_DOWNLOAD_FAILED ]
469469
@@ -509,7 +509,7 @@ def _validate_py_for_u_modules(self, download_url):
509509 """
510510 # We use requests because file contents are hosted by
511511 # githubusercontent.com, not the API domain.
512- contents = requests .get (download_url , timeout = 30 )
512+ contents = requests .get (download_url , timeout = REQUESTS_TIMEOUT )
513513 if not contents .ok :
514514 return [ERROR_PYFILE_DOWNLOAD_FAILED ]
515515
@@ -547,7 +547,7 @@ def _validate_actions_build_yml(self, actions_build_info):
547547 """
548548
549549 download_url = actions_build_info ["download_url" ]
550- contents = requests .get (download_url , timeout = 30 )
550+ contents = requests .get (download_url , timeout = REQUESTS_TIMEOUT )
551551 if not contents .ok :
552552 return [ERROR_PYFILE_DOWNLOAD_FAILED ]
553553
@@ -557,7 +557,7 @@ def _validate_actions_build_yml(self, actions_build_info):
557557
558558 def _validate_pre_commit_config_yaml (self , file_info ):
559559 download_url = file_info ["download_url" ]
560- contents = requests .get (download_url , timeout = 30 )
560+ contents = requests .get (download_url , timeout = REQUESTS_TIMEOUT )
561561 if not contents .ok :
562562 return [ERROR_PYFILE_DOWNLOAD_FAILED ]
563563
@@ -594,15 +594,15 @@ def _validate_pre_commit_config_yaml(self, file_info):
594594 def _validate_pyproject_toml (self , file_info ):
595595 """Check pyproject.toml for pypi compatibility"""
596596 download_url = file_info ["download_url" ]
597- contents = requests .get (download_url , timeout = 30 )
597+ contents = requests .get (download_url , timeout = REQUESTS_TIMEOUT )
598598 if not contents .ok :
599599 return [ERROR_TOMLFILE_DOWNLOAD_FAILED ]
600600 return []
601601
602602 def _validate_requirements_txt (self , repo , file_info , check_blinka = True ):
603603 """Check requirements.txt for pypi compatibility"""
604604 download_url = file_info ["download_url" ]
605- contents = requests .get (download_url , timeout = 30 )
605+ contents = requests .get (download_url , timeout = REQUESTS_TIMEOUT )
606606 if not contents .ok :
607607 return [ERROR_PYFILE_DOWNLOAD_FAILED ]
608608
@@ -717,7 +717,9 @@ def validate_contents(self, repo):
717717 if ".readthedocs.yaml" in files :
718718 filename = ".readthedocs.yaml"
719719 file_info = content_list [files .index (filename )]
720- rtd_contents = requests .get (file_info ["download_url" ])
720+ rtd_contents = requests .get (
721+ file_info ["download_url" ], timeout = REQUESTS_TIMEOUT
722+ )
721723 if rtd_contents .ok :
722724 try :
723725 rtd_yml = yaml .safe_load (rtd_contents .text )
@@ -735,7 +737,9 @@ def validate_contents(self, repo):
735737 if len (self ._pcc_versions ) or self .pcc_versions != "" :
736738 filename = ".pre-commit-config.yaml"
737739 file_info = content_list [files .index (filename )]
738- pcc_contents = requests .get (file_info ["download_url" ])
740+ pcc_contents = requests .get (
741+ file_info ["download_url" ], timeout = REQUESTS_TIMEOUT
742+ )
739743 if pcc_contents .ok :
740744 try :
741745 pcc_yml = yaml .safe_load (pcc_contents .text )
@@ -888,7 +892,8 @@ def validate_readthedocs(self, repo):
888892 return []
889893 if not self .rtd_subprojects :
890894 rtd_response = requests .get (
891- "https://readthedocs.org/api/v2/project/74557/subprojects/" , timeout = 15
895+ "https://readthedocs.org/api/v2/project/74557/subprojects/" ,
896+ timeout = REQUESTS_TIMEOUT ,
892897 )
893898 if not rtd_response .ok :
894899 return [ERROR_RTD_SUBPROJECT_FAILED ]
@@ -937,7 +942,7 @@ def validate_readthedocs(self, repo):
937942 url = f"https://readthedocs.org/api/v3/projects/{ rtd_slug } /builds/"
938943 rtd_token = os .environ ["RTD_TOKEN" ]
939944 headers = {"Authorization" : f"token { rtd_token } " }
940- response = requests .get (url , headers = headers )
945+ response = requests .get (url , headers = headers , timeout = REQUESTS_TIMEOUT )
941946 json_response = response .json ()
942947
943948 error_message = json_response .get ("detail" )
@@ -981,7 +986,7 @@ def validate_core_driver_page(self, repo):
981986 "https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/"
982987 "main/docs/drivers.rst"
983988 ),
984- timeout = 15 ,
989+ timeout = REQUESTS_TIMEOUT ,
985990 )
986991 if not driver_page .ok :
987992 return [ERROR_DRIVERS_PAGE_DOWNLOAD_FAILED ]
0 commit comments