1717import logging
1818from uuid import UUID
1919from typing import Union , List
20- from pydantic import BaseModel , validator , ValidationError , constr , conlist
20+
21+ # Pylint refrains from linting C extensions due to arbitrary code execution.
22+ from pydantic import BaseModel , constr , conlist # pylint:disable=no-name-in-module
23+ from pydantic import validator , ValidationError
2124import requests
2225from etos_api .library .docker import Docker
2326
27+ # pylint:disable=too-few-public-methods
28+
2429
2530class Environment (BaseModel ):
2631 """ETOS suite definion 'ENVIRONMENT' constraint."""
@@ -119,10 +124,8 @@ def validate_constraints(
119124 for constraint in value :
120125 model = cls .__constraint_models .get (constraint .key )
121126 if model is None :
122- raise TypeError (
123- "Unknown key %r, valid keys: %r"
124- % (constraint .key , tuple (cls .__constraint_models .keys ()))
125- )
127+ keys = tuple (cls .__constraint_models .keys ())
128+ raise TypeError (f"Unknown key { constraint .key } , valid keys: { keys } " )
126129 try :
127130 model (** constraint .dict ())
128131 except ValidationError as exception :
@@ -131,12 +134,12 @@ def validate_constraints(
131134 more_than_one = [key for key , number in count .items () if number > 1 ]
132135 if more_than_one :
133136 raise ValueError (
134- "Too many instances of keys %r . Only 1 allowed." % more_than_one
137+ f "Too many instances of keys { more_than_one } . Only 1 allowed."
135138 )
136139 missing = [key for key , number in count .items () if number == 0 ]
137140 if missing :
138141 raise ValueError (
139- "Too few instances of keys %r . At least 1 required." % missing
142+ f "Too few instances of keys { missing } . At least 1 required."
140143 )
141144 return value
142145
@@ -149,7 +152,7 @@ class Suite(BaseModel):
149152 recipes : List [Recipe ]
150153
151154
152- class SuiteValidator : # pylint:disable=too-few-public-methods
155+ class SuiteValidator :
153156 """Validate ETOS suite definitions to make sure they are executable."""
154157
155158 logger = logging .getLogger (__name__ )
@@ -163,11 +166,11 @@ async def _download_suite(self, test_suite_url):
163166 :rtype: list
164167 """
165168 try :
166- suite = requests .get (test_suite_url )
169+ suite = requests .get (test_suite_url , timeout = 60 )
167170 suite .raise_for_status ()
168171 except Exception as exception : # pylint:disable=broad-except
169172 raise AssertionError (
170- "Unable to download suite from %r" % test_suite_url
173+ f "Unable to download suite from { test_suite_url } "
171174 ) from exception
172175 return suite .json ()
173176
0 commit comments