Skip to content

Conversation

@drculhane
Copy link
Contributor

@drculhane drculhane commented Dec 26, 2025

Closes #5173

This one required a fair amount of work to satisfy mypy once the overloads were written. I'm going to keep it in draft initially.

Notes:

In addition to the work on the overloads, mypy found an error in the order of calling parameters to full in my recent PR that changed ak.minimum and ak.maximum. So that's been fixed.

Once the overloads were in place, mypy flagged an error in the use of full in isna function in the recent pandas extensions. I addressed that by converting the result of ak.full to an ArkoudaArray before returning.

@drculhane drculhane marked this pull request as ready for review January 12, 2026 19:54
@codecov-commenter
Copy link

codecov-commenter commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@9572ab3). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #5223   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?         4           
  Lines           ?        63           
  Branches        ?         0           
========================================
  Hits            ?        63           
  Misses          ?         0           
  Partials        ?         0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@ajpotts ajpotts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Copy link
Contributor

@1RyanK 1RyanK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

fill_value: Union[numeric_and_bool_scalars, str_scalars],
dtype: str,
max_bits: Optional[int] = ...,
) -> Strings: ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think although this doesn't "cause problems" with mypy, it does make mypy believe the wrong thing. For example, if you do ak.full(5, 7, dtype="int64"), mypy believes a Strings object will be returned. Here's a wacky, roundabout way to get that to show up:

In [13]: import textwrap, tempfile, os, sys, subprocess, pathlib
    ...: 
    ...: code = textwrap.dedent("""
    ...:     import arkouda as ak
    ...:     import numpy as np
    ...: 
    ...:     def f() -> None:
    ...:         a = ak.full(5, 7, dtype="int64")
    ...:         reveal_type(a)
    ...: 
    ...:         b = ak.full(5, 7, dtype="str")
    ...:         reveal_type(b)
    ...: 
    ...:         c = ak.full(5, "x")
    ...:         reveal_type(c)
    ...: 
    ...:         d = ak.full(5, np.nan)
    ...:         reveal_type(d)
    ...: """)
    ...: 
    ...: with tempfile.TemporaryDirectory() as td:
    ...:     p = pathlib.Path(td) / "mypy_check.py"
    ...:     p.write_text(code)
    ...: 
    ...:     # Run mypy. You might need: `pip install mypy` in your env first.
    ...:     res = subprocess.run(
    ...:         ["mypy", str(p)],
    ...:         capture_output=True,
    ...:         text=True,
    ...:     )
    ...:     print(res.stdout)
    ...:     print(res.stderr)
    ...: 
/tmp/tmpy9644sti/mypy_check.py:7: note: Revealed type is "arkouda.numpy.strings.Strings"
/tmp/tmpy9644sti/mypy_check.py:10: note: Revealed type is "arkouda.numpy.strings.Strings"
/tmp/tmpy9644sti/mypy_check.py:13: note: Revealed type is "arkouda.numpy.strings.Strings"
/tmp/tmpy9644sti/mypy_check.py:16: note: Revealed type is "arkouda.numpy.pdarrayclass.pdarray"
Success: no issues found in 1 source file

Notably, when it does

a = ak.full(5, 7, dtype="int64")
reveal_type(a)

The corresponding output is

/tmp/tmpy9644sti/mypy_check.py:7: note: Revealed type is "arkouda.numpy.strings.Strings"

But if you actually try it, you get int64. Maybe try

...
@overload
def full(
    size: ...,
    fill_value: Union[numeric_and_bool_scalars, str_scalars],
    dtype: Literal["str", "string"],
    max_bits: Optional[int] = ...,
) -> Strings: ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

overloads to full function

4 participants