77from dataclasses import replace
88from pathlib import Path
99from shutil import rmtree
10- from typing import TYPE_CHECKING , Callable , NamedTuple , Sequence
10+ from typing import TYPE_CHECKING , Callable , NamedTuple , Sequence , cast , reveal_type
1111
1212from noxopt import Annotated , NoxOpt , Option , Session
1313
@@ -41,8 +41,6 @@ def __call__(self, session: Session) -> Callable[[bool], None]:
4141 r"^"
4242 # package name
4343 r"(?P<name>[0-9a-zA-Z-@/]+)-"
44- # package language
45- rf"(?P<language>{ '|' .join (LANGUAGE_TYPES )} )-"
4644 # package version
4745 r"v(?P<version>[0-9][0-9a-zA-Z-\.\+]*)"
4846 # end
@@ -193,6 +191,7 @@ def check_python_types(session: Session) -> None:
193191 install_requirements_file (session , "pkg-extras" )
194192 session .run ("mypy" , "--version" )
195193 session .run ("mypy" , "--show-error-codes" , "--strict" , "src/reactpy" )
194+ session .run ("mypy" , "--show-error-codes" , "noxfile.py" )
196195
197196
198197@group .session
@@ -275,8 +274,8 @@ def publish(session: Session, dry_run: bool = False) -> None:
275274 "py" : prepare_python_release ,
276275 }
277276
278- publishers : list [Callable [[bool ], None ]] = []
279- for tag , tag_lang , tag_pkg , tag_ver in get_current_tags (session ):
277+ publishers : list [tuple [ Path , Callable [[bool ], None ] ]] = []
278+ for tag , tag_pkg , tag_ver in get_current_tags (session ):
280279 if tag_pkg not in packages :
281280 session .error (f"Tag { tag } references package { tag_pkg } that does not exist" )
282281
@@ -287,18 +286,12 @@ def publish(session: Session, dry_run: bool = False) -> None:
287286 f"but the current version is { pkg_ver } "
288287 )
289288
290- if pkg_lang != tag_lang :
291- session .error (
292- f"Tag { tag } references language { tag_lang } of package { tag_pkg } , "
293- f"but the current language is { pkg_lang } "
294- )
295-
296289 session .chdir (pkg_path )
297290 session .log (f"Preparing { tag_pkg } for release..." )
298- publishers .append ((pkg_path , release_prep [tag_lang ](session )))
291+ publishers .append ((pkg_path , release_prep [pkg_lang ](session )))
299292
300293 for pkg_path , publish in publishers :
301- session .log (f"Publishing { tag_pkg } ..." )
294+ session .log (f"Publishing { pkg_path } ..." )
302295 session .chdir (pkg_path )
303296 publish (dry_run )
304297
@@ -335,7 +328,7 @@ def prepare_javascript_release(session: Session) -> Callable[[bool], None]:
335328 if node_auth_token is None :
336329 session .error ("NODE_AUTH_TOKEN environment variable must be set" )
337330
338- # TODO: make this `ci` instead of `install` somehow. By default `npm install` at
331+ # TODO: Make this `ci` instead of `install` somehow. By default `npm install` at
339332 # workspace root does not generate a lockfile which is required by `npm ci`.
340333 session .run ("npm" , "install" , external = True )
341334
@@ -349,7 +342,7 @@ def publish(dry_run: bool) -> None:
349342 "--access" ,
350343 "public" ,
351344 external = True ,
352- env = {"NODE_AUTH_TOKEN" : node_auth_token },
345+ env = {"NODE_AUTH_TOKEN" : node_auth_token }, # type: ignore[dict-item]
353346 )
354347
355348 return publish
@@ -379,7 +372,7 @@ def publish(dry_run: bool):
379372 "twine" ,
380373 "upload" ,
381374 "dist/*" ,
382- env = {"TWINE_USERNAME" : twine_username , "TWINE_PASSWORD" : twine_password },
375+ env = {"TWINE_USERNAME" : twine_username , "TWINE_PASSWORD" : twine_password }, # type: ignore[dict-item]
383376 )
384377
385378 return publish
@@ -447,20 +440,23 @@ def get_current_tags(session: Session) -> list[TagInfo]:
447440 tags_per_commit : dict [str , list [str ]] = {}
448441 for commit , tag in map (
449442 str .split ,
450- session .run (
451- "git" ,
452- "for-each-ref" ,
453- "--format" ,
454- r"%(objectname) %(refname:short)" ,
455- "refs/tags" ,
456- silent = True ,
457- external = True ,
443+ cast (
444+ str ,
445+ session .run (
446+ "git" ,
447+ "for-each-ref" ,
448+ "--format" ,
449+ r"%(objectname) %(refname:short)" ,
450+ "refs/tags" ,
451+ silent = True ,
452+ external = True ,
453+ ),
458454 ).splitlines (),
459455 ):
460456 tags_per_commit .setdefault (commit , []).append (tag )
461457
462- current_commit = session . run (
463- "git" , "rev-parse" , "HEAD" , silent = True , external = True
458+ current_commit = cast (
459+ str , session . run ( "git" , "rev-parse" , "HEAD" , silent = True , external = True )
464460 ).strip ()
465461 tags = tags_per_commit .get (current_commit , [])
466462
@@ -477,7 +473,6 @@ def get_current_tags(session: Session) -> list[TagInfo]:
477473 parsed_tags .append (
478474 TagInfo (
479475 tag ,
480- match ["language" ],
481476 match ["name" ],
482477 match ["version" ],
483478 )
@@ -490,7 +485,6 @@ def get_current_tags(session: Session) -> list[TagInfo]:
490485
491486class TagInfo (NamedTuple ):
492487 tag : str
493- language : LanguageName
494488 package : str
495489 version : str
496490
@@ -510,6 +504,5 @@ def get_reactpy_package_version(session: Session) -> str:
510504 # remove the quotes
511505 [1 :- 1 ]
512506 )
513- break
514507 else :
515508 session .error (f"No version found in { pkg_root_init_file } " )
0 commit comments