Skip to content

PEP8 compliant names binding #83

Merged
jhonabreul merged 13 commits into
QuantConnect:masterfrom
jhonabreul:feature-snake-case-names-binding
Apr 11, 2024
Merged

PEP8 compliant names binding #83
jhonabreul merged 13 commits into
QuantConnect:masterfrom
jhonabreul:feature-snake-case-names-binding

Conversation

@jhonabreul

Copy link
Copy Markdown
Collaborator

Binding C# style names from C# method/fields/properties to PEP8 conforming names.

Examples:

  • Properties: C#'s SomePropertyName can be used in Python either with SomePropertyName or some_property_name. Ref: https://peps.python.org/pep-0008/#function-and-variable-names
  • Methods: same rule for properties.
    • Snake-cased methods also get their parameters snake-cased. So using named arguments must follow PEP8 naming.
  • Fields:
    • If fields are not constants, the same properties and methods rule applies.
    • Constant fields are snake-cased and upper-cased: C#'s SomeConstantField can be used in Python as SomeConstantField or SOME_CONSTANT_FIELD.
  • Enum values: same as constant fields, they are snake-cased and upper-cased.

@Martin-Molinero Martin-Molinero left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome work 💪 Minor comments shared


using var method = pyObj.GetAttr("another_int_property");
Assert.IsTrue(method.IsCallable());
Assert.AreEqual(654, method.Invoke().As<int>());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work 👍

@jhonabreul
jhonabreul merged commit 2d864c2 into QuantConnect:master Apr 11, 2024
@jhonabreul
jhonabreul deleted the feature-snake-case-names-binding branch April 11, 2024 19:48
jhonabreul added a commit that referenced this pull request Jul 9, 2026
…hod (#133)

* Fix IndexOutOfRangeException on empty **kwargs call to overloaded method (#132)

Calling an overloaded method with an empty kwargs mapping (e.g.
obj.Method(arg, **{}), common when forwarding *args/**kwargs from a
wrapper) crashed with an unhandled IndexOutOfRangeException in
MethodBinder.CheckMethodArgumentsMatch. Since 10e721b (PR #83), the
parameter names array is only populated when there are named arguments,
but the kwargs code paths only checked the kwargs dictionary for null,
so a non-null empty dict indexed into an empty names array.

Treat an empty kwargs dict as no keyword arguments, matching Python
semantics where f(x, **{}) is equivalent to f(x).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Update version to 2.0.60

Bump package <Version>, AssemblyVersion/AssemblyFileVersion and the
perf-test baseline reference to 2.0.60.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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