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 = [