Skip to content

Add structured dtype support for AnyVoidArray#584

Draft
Aniketsy wants to merge 6 commits into
jorenham:masterfrom
Aniketsy:fix-371
Draft

Add structured dtype support for AnyVoidArray#584
Aniketsy wants to merge 6 commits into
jorenham:masterfrom
Aniketsy:fix-371

Conversation

@Aniketsy

Copy link
Copy Markdown
Contributor

fixes #371

@Aniketsy
Aniketsy requested a review from jorenham as a code owner April 27, 2026 18:44
@github-actions github-actions Bot added the optype.numpy optional label Apr 27, 2026
@Aniketsy
Aniketsy marked this pull request as draft April 27, 2026 18:45
@github-actions

github-actions Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

mypy_primer results

✅ No ecosystem changes detected

@Aniketsy
Aniketsy marked this pull request as ready for review May 1, 2026 12:24
@Aniketsy

Aniketsy commented May 2, 2026

Copy link
Copy Markdown
Contributor Author
 INFO 0 errors (342 suppressed)
  mypy: OK (376.75=setup[318.94]+cmd[57.81] seconds)
  pyright: OK (360.36=setup[325.06]+cmd[35.31] seconds)
  pyrefly: OK (550.19=setup[537.84]+cmd[12.35] seconds)
  congratulations :) (1288.04 seconds)

😿

@jorenham

jorenham commented May 2, 2026

Copy link
Copy Markdown
Owner
 INFO 0 errors (342 suppressed)
  mypy: OK (376.75=setup[318.94]+cmd[57.81] seconds)
  pyright: OK (360.36=setup[325.06]+cmd[35.31] seconds)
  pyrefly: OK (550.19=setup[537.84]+cmd[12.35] seconds)
  congratulations :) (1288.04 seconds)

😿

The CI failures are for numpy<2.3, so I assume you locally have the latest NumPy installed. I'll take a look soon.

@Aniketsy

Aniketsy commented May 3, 2026

Copy link
Copy Markdown
Contributor Author
 INFO 0 errors (342 suppressed)
  mypy: OK (376.75=setup[318.94]+cmd[57.81] seconds)
  pyright: OK (360.36=setup[325.06]+cmd[35.31] seconds)
  pyrefly: OK (550.19=setup[537.84]+cmd[12.35] seconds)
  congratulations :) (1288.04 seconds)

😿

The CI failures are for numpy<2.3, so I assume you locally have the latest NumPy installed. I'll take a look soon.

yes, 2.4.4, please let me know if i can help with any step, should i look for the cause of ci failures.

Comment thread optype/numpy/_any_dtype.py Outdated
Comment on lines +11 to +13
from typing import NotRequired, TypeAliasType
else:
from typing import NotRequired

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

typing.NotRequired is imported in both branches, so it should be moved to the main typing import

Comment thread optype/numpy/_any_dtype.py Outdated


import numpy as np
import numpy.typing as npt

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

optype.numpy is intended as a complete replacement for numpy.typing, so this shouldn't be imported.

Comment thread optype/numpy/_any_dtype.py Outdated
Comment on lines +203 to +204
| tuple[str, npt.DTypeLike, int]
| tuple[str, npt.DTypeLike, tuple[int, ...]]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

these two can be combined

Comment thread optype/numpy/_any_dtype.py Outdated
Comment on lines +206 to +207
| tuple[tuple[Any, str], npt.DTypeLike, int]
| tuple[tuple[Any, str], npt.DTypeLike, tuple[int, ...]]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

same here

Comment thread optype/numpy/_any_dtype.py Outdated
Comment on lines +201 to +208
_StructuredDTypeField: TypeAlias = (
tuple[str, npt.DTypeLike]
| tuple[str, npt.DTypeLike, int]
| tuple[str, npt.DTypeLike, tuple[int, ...]]
| tuple[tuple[Any, str], npt.DTypeLike]
| tuple[tuple[Any, str], npt.DTypeLike, int]
| tuple[tuple[Any, str], npt.DTypeLike, tuple[int, ...]]
)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Like I said, we should use AnyDType here instead of npt.DTypeLike. That'd make this a recursive definition, so it's better to use TypeAliasType instead of TypeAlias.

Comment thread optype/numpy/_any_dtype.py Outdated
| Sequence[tuple[_ToName, _ToDType] | tuple[_ToName, _ToDType, _ToShape]]


class _StructuredDTypeDictForm1(TypedDict, total=True):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

total=True is the default

Suggested change
class _StructuredDTypeDictForm1(TypedDict, total=True):
class _StructuredDTypeDictForm1(TypedDict):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ehhh, these tests have nothing to do with AnyVoidDType. You're mostly testing numpy itself here, and also the (completely unrelated) optype.numpy.AnyVoidArray...

@Aniketsy
Aniketsy marked this pull request as draft June 3, 2026 13:18
@Aniketsy

Aniketsy commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

thanks for the review, i'm converting in draft for now, as this needs work.... actually i tried to rebase this pr from my tool 😁 which i built to automate and make smooth the rebase process (https://github.com/Aniketsy/grebase) as i used to mess up while rebasing....But i think i've done some mistakes so will rectify soon.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

optype.numpy.AnyVoidArray structured dtype support

2 participants