From 735252247371d466c7198cbc8e55865a07a75c05 Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Sun, 6 Oct 2024 20:22:40 +0200 Subject: [PATCH 1/7] docs: add check on Series.dt methods being in api-reference --- utils/check_api_reference.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/utils/check_api_reference.py b/utils/check_api_reference.py index 60e968a85..fd04b3b1b 100644 --- a/utils/check_api_reference.py +++ b/utils/check_api_reference.py @@ -157,7 +157,31 @@ print(missing) # noqa: T201 ret = 1 -# dt +# Series.dt methods +series_dt_methods = [ + i + for i in nw.from_native(pl.Series(), series_only=True).dt.__dir__() + if not i[0].isupper() and i[0] != "_" +] + +with open("docs/api-reference/series_dt.md") as fd: + content = fd.read() + +documented = [ + remove_prefix(i, " - ") + for i in content.splitlines() + if i.startswith(" - ") and not i.startswith(" - _") +] + +if missing := set(series_dt_methods).difference(documented): + print("Series.str: not documented") # noqa: T201 + print(missing) # noqa: T201 + ret = 1 + +if extra := set(documented).difference(series_dt_methods): + print("Series.str: outdated") # noqa: T201 + print(extra) # noqa: T201 + ret = 1 # Series.str methods series_str_methods = [ From ea27281f78aec81f2c2b55cd95d37c63841272b7 Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Sun, 6 Oct 2024 20:27:14 +0200 Subject: [PATCH 2/7] docs: add check on Series.cat methods being in api-reference --- utils/check_api_reference.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/utils/check_api_reference.py b/utils/check_api_reference.py index fd04b3b1b..5b6f8809b 100644 --- a/utils/check_api_reference.py +++ b/utils/check_api_reference.py @@ -157,6 +157,32 @@ print(missing) # noqa: T201 ret = 1 +# Series.cat methods +series_cat_methods = [ + i + for i in nw.from_native(pl.Series(), series_only=True).cat.__dir__() + if not i[0].isupper() and i[0] != "_" +] + +with open("docs/api-reference/series_cat.md") as fd: + content = fd.read() + +documented = [ + remove_prefix(i, " - ") + for i in content.splitlines() + if i.startswith(" - ") and not i.startswith(" - _") +] + +if missing := set(series_cat_methods).difference(documented): + print("Series.cat: not documented") # noqa: T201 + print(missing) # noqa: T201 + ret = 1 + +if extra := set(documented).difference(series_cat_methods): + print("Series.cat: outdated") # noqa: T201 + print(extra) # noqa: T201 + ret = 1 + # Series.dt methods series_dt_methods = [ i @@ -174,12 +200,12 @@ ] if missing := set(series_dt_methods).difference(documented): - print("Series.str: not documented") # noqa: T201 + print("Series.dt: not documented") # noqa: T201 print(missing) # noqa: T201 ret = 1 if extra := set(documented).difference(series_dt_methods): - print("Series.str: outdated") # noqa: T201 + print("Series.dt: outdated") # noqa: T201 print(extra) # noqa: T201 ret = 1 From 7b791439bbef8e999c18992c5611c8bd3e9a3c89 Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Sun, 6 Oct 2024 20:30:28 +0200 Subject: [PATCH 3/7] chore: remove extra blanks --- utils/check_api_reference.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/utils/check_api_reference.py b/utils/check_api_reference.py index 5b6f8809b..4eafe32b2 100644 --- a/utils/check_api_reference.py +++ b/utils/check_api_reference.py @@ -163,21 +163,17 @@ for i in nw.from_native(pl.Series(), series_only=True).cat.__dir__() if not i[0].isupper() and i[0] != "_" ] - with open("docs/api-reference/series_cat.md") as fd: content = fd.read() - documented = [ remove_prefix(i, " - ") for i in content.splitlines() if i.startswith(" - ") and not i.startswith(" - _") ] - if missing := set(series_cat_methods).difference(documented): print("Series.cat: not documented") # noqa: T201 print(missing) # noqa: T201 ret = 1 - if extra := set(documented).difference(series_cat_methods): print("Series.cat: outdated") # noqa: T201 print(extra) # noqa: T201 @@ -189,21 +185,17 @@ for i in nw.from_native(pl.Series(), series_only=True).dt.__dir__() if not i[0].isupper() and i[0] != "_" ] - with open("docs/api-reference/series_dt.md") as fd: content = fd.read() - documented = [ remove_prefix(i, " - ") for i in content.splitlines() if i.startswith(" - ") and not i.startswith(" - _") ] - if missing := set(series_dt_methods).difference(documented): print("Series.dt: not documented") # noqa: T201 print(missing) # noqa: T201 ret = 1 - if extra := set(documented).difference(series_dt_methods): print("Series.dt: outdated") # noqa: T201 print(extra) # noqa: T201 @@ -215,21 +207,17 @@ for i in nw.from_native(pl.Series(), series_only=True).str.__dir__() if not i[0].isupper() and i[0] != "_" ] - with open("docs/api-reference/series_str.md") as fd: content = fd.read() - documented = [ remove_prefix(i, " - ") for i in content.splitlines() if i.startswith(" - ") and not i.startswith(" - _") ] - if missing := set(series_str_methods).difference(documented): print("Series.str: not documented") # noqa: T201 print(missing) # noqa: T201 ret = 1 - if extra := set(documented).difference(series_str_methods): print("Series.str: outdated") # noqa: T201 print(extra) # noqa: T201 From e5854e86b9d8bddd54446d5b9c512ea0e052be12 Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Sun, 6 Oct 2024 20:45:24 +0200 Subject: [PATCH 4/7] docs: add check on documented, yet no longer existent methods on dtype --- utils/check_api_reference.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/check_api_reference.py b/utils/check_api_reference.py index 4eafe32b2..a781f67f9 100644 --- a/utils/check_api_reference.py +++ b/utils/check_api_reference.py @@ -156,6 +156,10 @@ print("Dtype: not documented") # noqa: T201 print(missing) # noqa: T201 ret = 1 +if extra := set(documented).difference(dtypes).difference(BASE_DTYPES): + print("Dtype: outdated") # noqa: T201 + print(extra) # noqa: T201 + ret = 1 # Series.cat methods series_cat_methods = [ From 0d34ad8f35c89b7fef28925217dae1a5a253b3aa Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Sun, 6 Oct 2024 21:05:39 +0200 Subject: [PATCH 5/7] docs: add check on Expr.{cat, dt, name, str} methods being in api-reference --- utils/check_api_reference.py | 80 ++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/utils/check_api_reference.py b/utils/check_api_reference.py index a781f67f9..7a9549694 100644 --- a/utils/check_api_reference.py +++ b/utils/check_api_reference.py @@ -141,6 +141,86 @@ print(extra) # noqa: T201 ret = 1 +# Expr.cat methods +expr_cat_methods = [ + i for i in nw.Expr(lambda: 0).cat.__dir__() if not i[0].isupper() and i[0] != "_" +] +with open("docs/api-reference/expr_cat.md") as fd: + content = fd.read() +documented = [ + remove_prefix(i, " - ") + for i in content.splitlines() + if i.startswith(" - ") +] +if missing := set(expr_cat_methods).difference(documented): + print("Expr.cat: not documented") # noqa: T201 + print(missing) # noqa: T201 + ret = 1 +if extra := set(documented).difference(expr_cat_methods): + print("Expr.cat: outdated") # noqa: T201 + print(extra) # noqa: T201 + ret = 1 + +# Expr.dt methods +expr_dt_methods = [ + i for i in nw.Expr(lambda: 0).dt.__dir__() if not i[0].isupper() and i[0] != "_" +] +with open("docs/api-reference/expr_dt.md") as fd: + content = fd.read() +documented = [ + remove_prefix(i, " - ") + for i in content.splitlines() + if i.startswith(" - ") +] +if missing := set(expr_dt_methods).difference(documented): + print("Expr.dt: not documented") # noqa: T201 + print(missing) # noqa: T201 + ret = 1 +if extra := set(documented).difference(expr_dt_methods): + print("Expr.dt: outdated") # noqa: T201 + print(extra) # noqa: T201 + ret = 1 + +# Expr.name methods +expr_name_methods = [ + i for i in nw.Expr(lambda: 0).name.__dir__() if not i[0].isupper() and i[0] != "_" +] +with open("docs/api-reference/expr_name.md") as fd: + content = fd.read() +documented = [ + remove_prefix(i, " - ") + for i in content.splitlines() + if i.startswith(" - ") +] +if missing := set(expr_name_methods).difference(documented): + print("Expr.name: not documented") # noqa: T201 + print(missing) # noqa: T201 + ret = 1 +if extra := set(documented).difference(expr_name_methods): + print("Expr.name: outdated") # noqa: T201 + print(extra) # noqa: T201 + ret = 1 + +# Expr.str methods +expr_str_methods = [ + i for i in nw.Expr(lambda: 0).str.__dir__() if not i[0].isupper() and i[0] != "_" +] +with open("docs/api-reference/expr_str.md") as fd: + content = fd.read() +documented = [ + remove_prefix(i, " - ") + for i in content.splitlines() + if i.startswith(" - ") +] +if missing := set(expr_str_methods).difference(documented): + print("Expr.str: not documented") # noqa: T201 + print(missing) # noqa: T201 + ret = 1 +if extra := set(documented).difference(expr_str_methods): + print("Expr.str: outdated") # noqa: T201 + print(extra) # noqa: T201 + ret = 1 + # DTypes dtypes = [ i for i in nw.dtypes.__dir__() if i[0].isupper() and not i.isupper() and i[0] != "_" From e989b7f87c098b0406e6eeda1bf0d9de2c853753 Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Sun, 6 Oct 2024 21:10:22 +0200 Subject: [PATCH 6/7] chore: remove useless check and move checks on Series.{cat, dt, str} higher up --- utils/check_api_reference.py | 134 +++++++++++++++++------------------ 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/utils/check_api_reference.py b/utils/check_api_reference.py index 7a9549694..42672a617 100644 --- a/utils/check_api_reference.py +++ b/utils/check_api_reference.py @@ -121,6 +121,72 @@ print(extra) # noqa: T201 ret = 1 +# Series.cat methods +series_cat_methods = [ + i + for i in nw.from_native(pl.Series(), series_only=True).cat.__dir__() + if not i[0].isupper() and i[0] != "_" +] +with open("docs/api-reference/series_cat.md") as fd: + content = fd.read() +documented = [ + remove_prefix(i, " - ") + for i in content.splitlines() + if i.startswith(" - ") and not i.startswith(" - _") +] +if missing := set(series_cat_methods).difference(documented): + print("Series.cat: not documented") # noqa: T201 + print(missing) # noqa: T201 + ret = 1 +if extra := set(documented).difference(series_cat_methods): + print("Series.cat: outdated") # noqa: T201 + print(extra) # noqa: T201 + ret = 1 + +# Series.dt methods +series_dt_methods = [ + i + for i in nw.from_native(pl.Series(), series_only=True).dt.__dir__() + if not i[0].isupper() and i[0] != "_" +] +with open("docs/api-reference/series_dt.md") as fd: + content = fd.read() +documented = [ + remove_prefix(i, " - ") + for i in content.splitlines() + if i.startswith(" - ") and not i.startswith(" - _") +] +if missing := set(series_dt_methods).difference(documented): + print("Series.dt: not documented") # noqa: T201 + print(missing) # noqa: T201 + ret = 1 +if extra := set(documented).difference(series_dt_methods): + print("Series.dt: outdated") # noqa: T201 + print(extra) # noqa: T201 + ret = 1 + +# Series.str methods +series_str_methods = [ + i + for i in nw.from_native(pl.Series(), series_only=True).str.__dir__() + if not i[0].isupper() and i[0] != "_" +] +with open("docs/api-reference/series_str.md") as fd: + content = fd.read() +documented = [ + remove_prefix(i, " - ") + for i in content.splitlines() + if i.startswith(" - ") and not i.startswith(" - _") +] +if missing := set(series_str_methods).difference(documented): + print("Series.str: not documented") # noqa: T201 + print(missing) # noqa: T201 + ret = 1 +if extra := set(documented).difference(series_str_methods): + print("Series.str: outdated") # noqa: T201 + print(extra) # noqa: T201 + ret = 1 + # Expr methods expr_methods = [ i for i in nw.Expr(lambda: 0).__dir__() if not i[0].isupper() and i[0] != "_" @@ -236,77 +302,11 @@ print("Dtype: not documented") # noqa: T201 print(missing) # noqa: T201 ret = 1 -if extra := set(documented).difference(dtypes).difference(BASE_DTYPES): +if extra := set(documented).difference(dtypes): print("Dtype: outdated") # noqa: T201 print(extra) # noqa: T201 ret = 1 -# Series.cat methods -series_cat_methods = [ - i - for i in nw.from_native(pl.Series(), series_only=True).cat.__dir__() - if not i[0].isupper() and i[0] != "_" -] -with open("docs/api-reference/series_cat.md") as fd: - content = fd.read() -documented = [ - remove_prefix(i, " - ") - for i in content.splitlines() - if i.startswith(" - ") and not i.startswith(" - _") -] -if missing := set(series_cat_methods).difference(documented): - print("Series.cat: not documented") # noqa: T201 - print(missing) # noqa: T201 - ret = 1 -if extra := set(documented).difference(series_cat_methods): - print("Series.cat: outdated") # noqa: T201 - print(extra) # noqa: T201 - ret = 1 - -# Series.dt methods -series_dt_methods = [ - i - for i in nw.from_native(pl.Series(), series_only=True).dt.__dir__() - if not i[0].isupper() and i[0] != "_" -] -with open("docs/api-reference/series_dt.md") as fd: - content = fd.read() -documented = [ - remove_prefix(i, " - ") - for i in content.splitlines() - if i.startswith(" - ") and not i.startswith(" - _") -] -if missing := set(series_dt_methods).difference(documented): - print("Series.dt: not documented") # noqa: T201 - print(missing) # noqa: T201 - ret = 1 -if extra := set(documented).difference(series_dt_methods): - print("Series.dt: outdated") # noqa: T201 - print(extra) # noqa: T201 - ret = 1 - -# Series.str methods -series_str_methods = [ - i - for i in nw.from_native(pl.Series(), series_only=True).str.__dir__() - if not i[0].isupper() and i[0] != "_" -] -with open("docs/api-reference/series_str.md") as fd: - content = fd.read() -documented = [ - remove_prefix(i, " - ") - for i in content.splitlines() - if i.startswith(" - ") and not i.startswith(" - _") -] -if missing := set(series_str_methods).difference(documented): - print("Series.str: not documented") # noqa: T201 - print(missing) # noqa: T201 - ret = 1 -if extra := set(documented).difference(series_str_methods): - print("Series.str: outdated") # noqa: T201 - print(extra) # noqa: T201 - ret = 1 - # Check Expr vs Series expr = [i for i in nw.Expr(lambda: 0).__dir__() if not i[0].isupper() and i[0] != "_"] series = [ From d9b361eedc17dfcf5aaf351e85c573d6fef8c7cc Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Sun, 6 Oct 2024 21:58:58 +0200 Subject: [PATCH 7/7] docs: apply suggested changes --- utils/check_api_reference.py | 190 +++++++++-------------------------- 1 file changed, 46 insertions(+), 144 deletions(-) diff --git a/utils/check_api_reference.py b/utils/check_api_reference.py index 42672a617..7bc590423 100644 --- a/utils/check_api_reference.py +++ b/utils/check_api_reference.py @@ -121,71 +121,30 @@ print(extra) # noqa: T201 ret = 1 -# Series.cat methods -series_cat_methods = [ - i - for i in nw.from_native(pl.Series(), series_only=True).cat.__dir__() - if not i[0].isupper() and i[0] != "_" -] -with open("docs/api-reference/series_cat.md") as fd: - content = fd.read() -documented = [ - remove_prefix(i, " - ") - for i in content.splitlines() - if i.startswith(" - ") and not i.startswith(" - _") -] -if missing := set(series_cat_methods).difference(documented): - print("Series.cat: not documented") # noqa: T201 - print(missing) # noqa: T201 - ret = 1 -if extra := set(documented).difference(series_cat_methods): - print("Series.cat: outdated") # noqa: T201 - print(extra) # noqa: T201 - ret = 1 - -# Series.dt methods -series_dt_methods = [ - i - for i in nw.from_native(pl.Series(), series_only=True).dt.__dir__() - if not i[0].isupper() and i[0] != "_" -] -with open("docs/api-reference/series_dt.md") as fd: - content = fd.read() -documented = [ - remove_prefix(i, " - ") - for i in content.splitlines() - if i.startswith(" - ") and not i.startswith(" - _") -] -if missing := set(series_dt_methods).difference(documented): - print("Series.dt: not documented") # noqa: T201 - print(missing) # noqa: T201 - ret = 1 -if extra := set(documented).difference(series_dt_methods): - print("Series.dt: outdated") # noqa: T201 - print(extra) # noqa: T201 - ret = 1 - -# Series.str methods -series_str_methods = [ - i - for i in nw.from_native(pl.Series(), series_only=True).str.__dir__() - if not i[0].isupper() and i[0] != "_" -] -with open("docs/api-reference/series_str.md") as fd: - content = fd.read() -documented = [ - remove_prefix(i, " - ") - for i in content.splitlines() - if i.startswith(" - ") and not i.startswith(" - _") -] -if missing := set(series_str_methods).difference(documented): - print("Series.str: not documented") # noqa: T201 - print(missing) # noqa: T201 - ret = 1 -if extra := set(documented).difference(series_str_methods): - print("Series.str: outdated") # noqa: T201 - print(extra) # noqa: T201 - ret = 1 +# Series.{cat, dt, str} methods +for namespace in NAMESPACES.difference({"name"}): + series_methods = [ + i + for i in getattr( + nw.from_native(pl.Series(), series_only=True), namespace + ).__dir__() + if not i[0].isupper() and i[0] != "_" + ] + with open(f"docs/api-reference/series_{namespace}.md") as fd: + content = fd.read() + documented = [ + remove_prefix(i, " - ") + for i in content.splitlines() + if i.startswith(" - ") and not i.startswith(" - _") + ] + if missing := set(series_methods).difference(documented): + print(f"Series.{namespace}: not documented") # noqa: T201 + print(missing) # noqa: T201 + ret = 1 + if extra := set(documented).difference(series_methods): + print(f"Series.{namespace}: outdated") # noqa: T201 + print(extra) # noqa: T201 + ret = 1 # Expr methods expr_methods = [ @@ -207,85 +166,28 @@ print(extra) # noqa: T201 ret = 1 -# Expr.cat methods -expr_cat_methods = [ - i for i in nw.Expr(lambda: 0).cat.__dir__() if not i[0].isupper() and i[0] != "_" -] -with open("docs/api-reference/expr_cat.md") as fd: - content = fd.read() -documented = [ - remove_prefix(i, " - ") - for i in content.splitlines() - if i.startswith(" - ") -] -if missing := set(expr_cat_methods).difference(documented): - print("Expr.cat: not documented") # noqa: T201 - print(missing) # noqa: T201 - ret = 1 -if extra := set(documented).difference(expr_cat_methods): - print("Expr.cat: outdated") # noqa: T201 - print(extra) # noqa: T201 - ret = 1 - -# Expr.dt methods -expr_dt_methods = [ - i for i in nw.Expr(lambda: 0).dt.__dir__() if not i[0].isupper() and i[0] != "_" -] -with open("docs/api-reference/expr_dt.md") as fd: - content = fd.read() -documented = [ - remove_prefix(i, " - ") - for i in content.splitlines() - if i.startswith(" - ") -] -if missing := set(expr_dt_methods).difference(documented): - print("Expr.dt: not documented") # noqa: T201 - print(missing) # noqa: T201 - ret = 1 -if extra := set(documented).difference(expr_dt_methods): - print("Expr.dt: outdated") # noqa: T201 - print(extra) # noqa: T201 - ret = 1 - -# Expr.name methods -expr_name_methods = [ - i for i in nw.Expr(lambda: 0).name.__dir__() if not i[0].isupper() and i[0] != "_" -] -with open("docs/api-reference/expr_name.md") as fd: - content = fd.read() -documented = [ - remove_prefix(i, " - ") - for i in content.splitlines() - if i.startswith(" - ") -] -if missing := set(expr_name_methods).difference(documented): - print("Expr.name: not documented") # noqa: T201 - print(missing) # noqa: T201 - ret = 1 -if extra := set(documented).difference(expr_name_methods): - print("Expr.name: outdated") # noqa: T201 - print(extra) # noqa: T201 - ret = 1 - -# Expr.str methods -expr_str_methods = [ - i for i in nw.Expr(lambda: 0).str.__dir__() if not i[0].isupper() and i[0] != "_" -] -with open("docs/api-reference/expr_str.md") as fd: - content = fd.read() -documented = [ - remove_prefix(i, " - ") - for i in content.splitlines() - if i.startswith(" - ") -] -if missing := set(expr_str_methods).difference(documented): - print("Expr.str: not documented") # noqa: T201 - print(missing) # noqa: T201 - ret = 1 -if extra := set(documented).difference(expr_str_methods): - print("Expr.str: outdated") # noqa: T201 - print(extra) # noqa: T201 - ret = 1 +# Expr.{cat, dt, name, str} methods +for namespace in NAMESPACES: + expr_methods = [ + i + for i in getattr(nw.Expr(lambda: 0), namespace).__dir__() + if not i[0].isupper() and i[0] != "_" + ] + with open(f"docs/api-reference/expr_{namespace}.md") as fd: + content = fd.read() + documented = [ + remove_prefix(i, " - ") + for i in content.splitlines() + if i.startswith(" - ") + ] + if missing := set(expr_methods).difference(documented): + print(f"Expr.{namespace}: not documented") # noqa: T201 + print(missing) # noqa: T201 + ret = 1 + if extra := set(documented).difference(expr_methods): + print(f"Expr.{namespace}: outdated") # noqa: T201 + print(extra) # noqa: T201 + ret = 1 # DTypes dtypes = [