Skip to content

Eliminate from ... import * in wasmtime.* - #304

Merged
alexcrichton merged 2 commits into
bytecodealliance:mainfrom
moreati:eliminate-star-imports
Nov 8, 2025
Merged

alexcrichton merged 2 commits into
bytecodealliance:mainfrom
moreati:eliminate-star-imports

Conversation

@moreati

@moreati moreati commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

On a hunch I thought one or more of the from ... import * might be triggering or influencing #302, so I tried removing them. This is result, it did not fix #302, I'm creating this PR mainly on the off chance there is any interest.

Otherwise please feel free to ignore/close it. The number of changed lines is quite a high, for a low to middling benefit.

@moreati

moreati commented Nov 6, 2025

Copy link
Copy Markdown
Contributor Author
  1. Would you be interested in eliminating from ... import *?
  2. If so would you prefer replaceing those with
    a. import foo (lots of changed lines no need to change imports much going forward)
    b. from foo import x, y,, z, ... (few changed lines now, more in the future)
    c. some mix of a and b?

My preference would be a, but I'm fine with b or c.

@alexcrichton

Copy link
Copy Markdown
Member

I think it's reasonable yeah! I'm happy to defer to whichever style you feel is best, I don't have a strong preference myself

One case is left for now in wasmtime._ffi, in the interest of keeping the PR less huge.
@moreati
moreati force-pushed the eliminate-star-imports branch from 528a11e to 2a8cbc9 Compare November 7, 2025 15:54
@moreati

moreati commented Nov 7, 2025

Copy link
Copy Markdown
Contributor Author

Hitting #303, a type mismatch in wamtime._value.unintern between int and ctypes Pointer.

@moreati

moreati commented Nov 7, 2025

Copy link
Copy Markdown
Contributor Author

I think 2a8cbc9 is the most I should do in a single PR, to leave it reviewable.

I've prototyped one followup

  • Rename _bindings.py -> _ffi/init.py & break up _ffi.py -> _ffi/_lib.py, _ffi/_types.py, _ffi./_util.py

This eliminates the one remaining import * in wasmtime.*, and breaks up an import cycle between _bindings.py & _ffi.py.

I'll try to look at #303 next week.

@moreati moreati changed the title WIP: Eliminate from ... import * Eliminate from ... import * in wasmtime.* Nov 7, 2025
@moreati

moreati commented Nov 7, 2025

Copy link
Copy Markdown
Contributor Author

main...moreati:wasmtime-py:split-up contains the followup WIP

@alexcrichton

Copy link
Copy Markdown
Member

I have vague recollections of historically mypy and ctypes basically don't work together. I tried my best in various locations to get things to work but I almost surely bungled it in various places. I forget what is necessary to get things working or why things are the way they are though unfortunately.

@moreati
moreati marked this pull request as ready for review November 8, 2025 18:37
@alexcrichton
alexcrichton merged commit 751d2e7 into bytecodealliance:main Nov 8, 2025
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.

"TypeError: 'NoneType' object is not callable" during calls to wasmtime.Managed.__del__

2 participants