Skip to content

Keep pythonnet overloads hint in NoMethodMatchPythonExceptionInterpreter message#9594

Merged
jhonabreul merged 1 commit into
QuantConnect:masterfrom
jhonabreul:bug-nomethodmatch-keep-overload-hints
Jul 7, 2026
Merged

Keep pythonnet overloads hint in NoMethodMatchPythonExceptionInterpreter message#9594
jhonabreul merged 1 commit into
QuantConnect:masterfrom
jhonabreul:bug-nomethodmatch-keep-overload-hints

Conversation

@jhonabreul

Copy link
Copy Markdown
Collaborator

Description

Since pythonnet 2.0.57, the "No method matches given arguments" TypeError message includes the candidate signatures so the caller can see what the method expects:

No method matches given arguments for rsi: (<class 'QuantConnect.Symbol'>, <class 'int'>, <class 'QuantConnect.Resolution'>). The expected signature is:
  rsi(Symbol symbol, Int32 period, MovingAverageType moving_average_type = Wilders, Resolution? resolution = None, Func[IBaseData, Decimal] selector = None)

NoMethodMatchPythonExceptionInterpreter replaced the original message with a friendly one built from the parsed method name, discarding that hint. The hint section ("The expected signature is:" / "The following overloads are available:" plus the signatures) is now extracted from the original message and appended to the interpreted one:

Trying to dynamically access a method that does not exist throws a TypeError exception. To prevent the exception, ensure each parameter type matches those required by the rsi method. Please checkout the API documentation. The expected signature is:
rsi(Symbol symbol, Int32 period, MovingAverageType moving_average_type = Wilders, Resolution? resolution = None, Func[IBaseData, Decimal] selector = None)

Related Issue

N/A — follow-up to #9573; the hint was reported missing from interpreted messages of Python algorithms failing overload resolution (e.g. self.limit_order(symbol, contracts, entry, "tag"), where the hint reveals the tag must be passed as a keyword since the asynchronous parameter was introduced).

Motivation and Context

The signatures hint is the part of the message that tells users which parameter didn't match and how to fix the call; dropping it left only the method name.

Requires Documentation Change

No.

How Has This Been Tested?

Added two tests to NoMethodMatchPythonExceptionInterpreterTests, one per hint wording:

  • VerifyMessageKeepsTheOverloadsHintset_cash('SPY') (multiple candidates, "The following overloads are available:").
  • VerifyMessageKeepsTheExpectedSignatureHintrsi(symbol, 15, Resolution.DAILY) (candidates collapse to a single signature, "The expected signature is:").

Both fail before the fix and pass after. Full NoMethodMatchPythonExceptionInterpreterTests fixture passes (15/15) and the whole Tests.Common.Exceptions suite passes (103/103).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

🤖 Generated with Claude Code

…ter message

The interpreter replaced the original pythonnet binding-failure message
with a friendly one built from the parsed method name, discarding the
candidate-signatures hint pythonnet 2.0.57+ appends ("The expected
signature is:" / "The following overloads are available:" followed by
the signatures). That hint is what lets users see which parameter
didn't match, so extract it from the original message and append it to
the interpreted one.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jhonabreul jhonabreul merged commit cf6ad51 into QuantConnect:master Jul 7, 2026
7 of 9 checks passed
@jhonabreul jhonabreul deleted the bug-nomethodmatch-keep-overload-hints branch July 7, 2026 20:17
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.

2 participants