PythonKit icon indicating copy to clipboard operation
PythonKit copied to clipboard

Cleanup warnings and failures in tests.

Open jeffdav opened this issue 1 year ago • 1 comments

There were two warnings.

Warning #1:

Users/jeffdav/src/jeffdav-PythonKit/PythonKit/NumpyConversion.swift:140:34: warning: 'assign(from:count:)' is deprecated: renamed to 'update(from:count:)'
            buffPtr.baseAddress!.assign(from: ptr, count: scalarCount)
                                 ^
/Users/jeffdav/src/jeffdav-PythonKit/PythonKit/NumpyConversion.swift:140:34: note: use 'update(from:count:)' instead
            buffPtr.baseAddress!.assign(from: ptr, count: scalarCount)
                                 ^~~~~~
                                 update

Warning #2:

/Users/jeffdav/src/jeffdav-PythonKit/Tests/PythonKitTests/PythonFunctionTests.swift:207:13: warning: initialization of immutable value 'testFunction' was never used; consider replacing with assignment to '_' or removing it
        let testFunction = PythonFunction { _ in
        ~~~~^~~~~~~~~~~~
        _

This fixes both warnings in the obvious ways.

There was one failure when I ran the test suite locally:

/Users/jeffdav/src/jeffdav-PythonKit/Tests/PythonKitTests/PythonRuntimeTests.swift:197: error: -[PythonKitTests.PythonRuntimeTests testErrors] : XCTAssertEqual failed: ("str") is not equal to ("ZeroDivisionError")

Investigation shows that something changed between Python 3.11 and 3.12 in this area:

--> Python 3.11.9:
po exception
 division by zero
po exception.__class__
 <class 'str'>
po exception.__class__.__name__
 str

--> Python 3.12.4:
po exception
 division by zero
po exception.__class__
 <class 'ZeroDivisionError'>
po exception.__class__.__name__
 ZeroDivisionError

We're still using 3.11.9 locally and this was annoying me so I added a check to make it work in both scenarios. If there's a better way, I'm happy to do something else.

jeffdav avatar Aug 19 '24 23:08 jeffdav

The whitespace changes really make it difficult to identify the actual change from the whitespace change. Could you please split that out into a separate change? We can get that in trivially, the other change, I'd like to understand a bit further.

compnerd avatar Aug 21 '24 04:08 compnerd

@compnerd https://github.com/pvieito/PythonKit/pull/63

jeffdav avatar Aug 25 '24 00:08 jeffdav

Will reopen.

jeffdav avatar Aug 25 '24 00:08 jeffdav