7
7
from dataclasses import replace
8
8
from pathlib import Path
9
9
from shutil import rmtree
10
- from typing import TYPE_CHECKING , Callable , NamedTuple , Sequence
10
+ from typing import TYPE_CHECKING , Callable , NamedTuple , Sequence , cast , reveal_type
11
11
12
12
from noxopt import Annotated , NoxOpt , Option , Session
13
13
@@ -41,8 +41,6 @@ def __call__(self, session: Session) -> Callable[[bool], None]:
41
41
r"^"
42
42
# package name
43
43
r"(?P<name>[0-9a-zA-Z-@/]+)-"
44
- # package language
45
- rf"(?P<language>{ '|' .join (LANGUAGE_TYPES )} )-"
46
44
# package version
47
45
r"v(?P<version>[0-9][0-9a-zA-Z-\.\+]*)"
48
46
# end
@@ -193,6 +191,7 @@ def check_python_types(session: Session) -> None:
193
191
install_requirements_file (session , "pkg-extras" )
194
192
session .run ("mypy" , "--version" )
195
193
session .run ("mypy" , "--show-error-codes" , "--strict" , "src/reactpy" )
194
+ session .run ("mypy" , "--show-error-codes" , "noxfile.py" )
196
195
197
196
198
197
@group .session
@@ -275,8 +274,8 @@ def publish(session: Session, dry_run: bool = False) -> None:
275
274
"py" : prepare_python_release ,
276
275
}
277
276
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 ):
280
279
if tag_pkg not in packages :
281
280
session .error (f"Tag { tag } references package { tag_pkg } that does not exist" )
282
281
@@ -287,18 +286,12 @@ def publish(session: Session, dry_run: bool = False) -> None:
287
286
f"but the current version is { pkg_ver } "
288
287
)
289
288
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
-
296
289
session .chdir (pkg_path )
297
290
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 )))
299
292
300
293
for pkg_path , publish in publishers :
301
- session .log (f"Publishing { tag_pkg } ..." )
294
+ session .log (f"Publishing { pkg_path } ..." )
302
295
session .chdir (pkg_path )
303
296
publish (dry_run )
304
297
@@ -335,7 +328,7 @@ def prepare_javascript_release(session: Session) -> Callable[[bool], None]:
335
328
if node_auth_token is None :
336
329
session .error ("NODE_AUTH_TOKEN environment variable must be set" )
337
330
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
339
332
# workspace root does not generate a lockfile which is required by `npm ci`.
340
333
session .run ("npm" , "install" , external = True )
341
334
@@ -349,7 +342,7 @@ def publish(dry_run: bool) -> None:
349
342
"--access" ,
350
343
"public" ,
351
344
external = True ,
352
- env = {"NODE_AUTH_TOKEN" : node_auth_token },
345
+ env = {"NODE_AUTH_TOKEN" : node_auth_token }, # type: ignore[dict-item]
353
346
)
354
347
355
348
return publish
@@ -379,7 +372,7 @@ def publish(dry_run: bool):
379
372
"twine" ,
380
373
"upload" ,
381
374
"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]
383
376
)
384
377
385
378
return publish
@@ -447,20 +440,23 @@ def get_current_tags(session: Session) -> list[TagInfo]:
447
440
tags_per_commit : dict [str , list [str ]] = {}
448
441
for commit , tag in map (
449
442
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
+ ),
458
454
).splitlines (),
459
455
):
460
456
tags_per_commit .setdefault (commit , []).append (tag )
461
457
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 )
464
460
).strip ()
465
461
tags = tags_per_commit .get (current_commit , [])
466
462
@@ -477,7 +473,6 @@ def get_current_tags(session: Session) -> list[TagInfo]:
477
473
parsed_tags .append (
478
474
TagInfo (
479
475
tag ,
480
- match ["language" ],
481
476
match ["name" ],
482
477
match ["version" ],
483
478
)
@@ -490,7 +485,6 @@ def get_current_tags(session: Session) -> list[TagInfo]:
490
485
491
486
class TagInfo (NamedTuple ):
492
487
tag : str
493
- language : LanguageName
494
488
package : str
495
489
version : str
496
490
@@ -510,6 +504,5 @@ def get_reactpy_package_version(session: Session) -> str:
510
504
# remove the quotes
511
505
[1 :- 1 ]
512
506
)
513
- break
514
507
else :
515
508
session .error (f"No version found in { pkg_root_init_file } " )
0 commit comments