@@ -81,13 +81,17 @@ def from_json(cls, ver: str, metadata: dict[str, t.Any]) -> PythonRelease:
8181 end_of_life = _parse_eol_date (metadata ["end_of_life" ]),
8282 )
8383
84- def is_eol (self , cached : bool ) -> bool :
85- """Check if this version is end-of-life."""
84+ def is_eol (self , use_system_date : bool ) -> bool :
85+ """
86+ Check if this version is end-of-life.
87+
88+ If `use_system_date` is `True`, an additional date-based check is performed for versions
89+ that are not explicitly EOL.
90+ """
8691 if self .status == ReleasePhase .EOL :
8792 return True
8893
89- # When running cached, don't use the current date, and trust .status
90- if not cached :
94+ if use_system_date :
9195 utc_today = dt .datetime .now (dt .timezone .utc ).date ()
9296 if self .end_of_life <= utc_today :
9397 return True
@@ -114,13 +118,16 @@ def _get_cached_release_cycle(cache_json: Path) -> list[PythonRelease]:
114118
115119
116120def check_python_support (
117- toml_file : Path , * , cached : bool = False , cache_json : Path = CACHED_RELEASE_CYCLE
121+ toml_file : Path , cache_json : Path = CACHED_RELEASE_CYCLE , use_system_date : bool = True
118122) -> None :
119123 """
120124 Check the input TOML's `requires-python` for overlap with EOL Python version(s).
121125
122126 If overlap(s) are present, an exception is raised whose message enumerates all EOL Python
123127 versions supported by the TOML file.
128+
129+ If `use_system_date` is `True`, an additional date-based check is performed for versions that
130+ are not explicitly EOL.
124131 """
125132 with toml_file .open ("rb" ) as f :
126133 contents = tomllib .load (f )
@@ -132,7 +139,9 @@ def check_python_support(
132139 package_spec = specifiers .SpecifierSet (requires_python )
133140 release_cycle = _get_cached_release_cycle (cache_json )
134141
135- eol_supported = [r for r in release_cycle if r .python_ver in package_spec and r .is_eol (cached )]
142+ eol_supported = [
143+ r for r in release_cycle if ((r .python_ver in package_spec ) and r .is_eol (use_system_date ))
144+ ]
136145
137146 if eol_supported :
138147 eol_supported .sort (key = attrgetter ("python_ver" )) # Sort ascending for error msg generation
@@ -143,13 +152,13 @@ def check_python_support(
143152def main (argv : abc .Sequence [str ] | None = None ) -> int : # noqa: D103
144153 parser = argparse .ArgumentParser ()
145154 parser .add_argument ("filenames" , nargs = "*" , type = Path )
146- parser .add_argument ("--cached " , action = "store_true" )
155+ parser .add_argument ("--cache_only " , action = "store_true" )
147156 args = parser .parse_args (argv )
148157
149158 ec = 0
150159 for file in args .filenames :
151160 try :
152- check_python_support (file , cached = args .cached )
161+ check_python_support (file , use_system_date = ( not args .cache_only ) )
153162 except EOLPythonError as e :
154163 print (f"{ file } : { e } " )
155164 ec = 1
0 commit comments