Skip to content

Commit

Permalink
feat: maketqdm.Tqdm! polymorphic
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Nov 18, 2023
1 parent d1919af commit 439ba1d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- run: pip install tqdm
- uses: erg-lang/[email protected]
- run: |
git config user.name github-actions[bot]
Expand Down
6 changes: 5 additions & 1 deletion crates/erg_compiler/context/inquire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2228,7 +2228,11 @@ impl Context {
"{instance} is quantified subr"
);
log!(info "Substituted:\ninstance: {instance}");
debug_assert!(instance.has_no_qvar(), "{instance} has qvar");
debug_assert!(
instance.is_type() || instance.has_no_qvar(),
"{instance} has qvar (obj: {obj}, attr: {}",
fmt_option!(attr_name)
);
if let Some((expected, instance)) = expected_return.zip(instance.return_t()) {
let _res = self.sub_unify(instance, expected, obj, None);
}
Expand Down
10 changes: 5 additions & 5 deletions crates/erg_compiler/lib/external/tqdm.d/__init__.d.er
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.Tqdm! = 'tqdm': ClassType
.Tqdm! <: Iterable Int
.Tqdm!.
.Tqdm! = 'tqdm': (T: Type) -> ClassType
.Tqdm!(T) <: Iterable T
.Tqdm!(T).
# TODO: iterable should be Comparable
__call__: (
iterable: Iterable(Int),
iterable: Iterable(T),
desc := Str,
total := Int or Float,
leave := Bool,
Expand All @@ -29,4 +29,4 @@
colour := Str,
delay := Float,
gui := Bool,
) -> .Tqdm!
) -> .Tqdm!(T)
15 changes: 8 additions & 7 deletions doc/scripts/sync_to_translation_status.er
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
os = pyimport "os"
re = pyimport "re"
mylib = pyimport "mylib" # TODO: Make it work without this
tqdm = pyimport "tqdm"

LANGUAGES_KEBAB_CASE = ["JA", "zh-TW", "zh-CN"]

Expand All @@ -14,8 +15,8 @@ cwd = os.getcwd!()

badge_pattern = re.compile("\\[!\\[badge\\]\\(([\\w.,@?^=%&:\\/~+#-]+)\\)\\]\\(([\\w.,@?^=%&:\\/~+#-]+)\\)")

get_bedge! file_path =
if! os.path.exists!(file_path):
get_badge! file_path =
if! os.path.exists!(file_path) and os.path.isfile!(file_path):
do!:
with! open!(file_path, encoding := "utf-8"), f =>
badge_match = badge_pattern.search(f.read!())
Expand Down Expand Up @@ -55,13 +56,13 @@ for! LANGUAGES_KEBAB_CASE, lang =>

add_table_row_text! "EN file name", "edit icon and badge"
add_table_row_text! "---", "---"
add_table_row_text! "[README.md](../../README.md)", "[📝](../../README_\{lang}.md) \{get_bedge!(mylib.path_join(cwd, "../README_\{lang}.md"))}"
add_table_row_text! "[CODE_OF_CONDUCT.md](../../CODE_OF_CONDUCT.md)", "[📝](../CODE_OF_CONDUCT/CODE_OF_CONDUCT_\{lang}.md) \{get_bedge!(mylib.path_join(cwd, "./CODE_OF_CONDUCT/CODE_OF_CONDUCT_\{lang}.md"))}"
add_table_row_text! "[CONTRIBUTING.md](../../CONTRIBUTING.md)", "[📝](../CONTRIBUTING/CONTRIBUTING_\{lang}.md) \{get_bedge!(mylib.path_join(cwd, "./CONTRIBUTING/CONTRIBUTING_\{lang}.md"))}"
add_table_row_text! "[README.md](../../README.md)", "[📝](../../README_\{lang}.md) \{get_badge!(mylib.path_join(cwd, "../README_\{lang}.md"))}"
add_table_row_text! "[CODE_OF_CONDUCT.md](../../CODE_OF_CONDUCT.md)", "[📝](../CODE_OF_CONDUCT/CODE_OF_CONDUCT_\{lang}.md) \{get_badge!(mylib.path_join(cwd, "./CODE_OF_CONDUCT/CODE_OF_CONDUCT_\{lang}.md"))}"
add_table_row_text! "[CONTRIBUTING.md](../../CONTRIBUTING.md)", "[📝](../CONTRIBUTING/CONTRIBUTING_\{lang}.md) \{get_badge!(mylib.path_join(cwd, "./CONTRIBUTING/CONTRIBUTING_\{lang}.md"))}"

for! doc_en_file_paths, en_path =>
for! tqdm.Tqdm!(doc_en_file_paths), en_path =>
relative_file_path = "\{lang.replace "-", "_"}\{mylib.str_slice en_path, 2}"
add_table_row_text! "[\{mylib.str_slice en_path, 3}](../\{en_path})", "[📝](../\{relative_file_path}) \{get_bedge!(mylib.path_join(cwd, relative_file_path))}"
add_table_row_text! "[\{mylib.str_slice en_path, 3}](../\{en_path})", "[📝](../\{relative_file_path}) \{get_badge!(mylib.path_join(cwd, relative_file_path))}"

with! open!(mylib.path_join(cwd, mylib.path_join("translation_status", "translation_status_\{lang}.md")), encoding := "utf-8", mode := "w"), f =>
discard f.write! str(result_text)

0 comments on commit 439ba1d

Please sign in to comment.