Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions QuantConnectStubsGenerator.Tests/RendererTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ public List<Dictionary<T1, T2>> TestMethod3(T1 t1Param, List<Dictionary<T1, List

public class TestClass : TestGenericClass<Symbol, DateTime>
{
public void TestMethod3(int number, DateTime time) {}
}
}"
}
Expand Down Expand Up @@ -605,8 +606,13 @@ class TestClass(QuantConnect.Test.TestGenericClass[QuantConnect.Symbol, datetime
def test_method_1(self, t_1_param: typing.Union[QuantConnect.Symbol, str, QuantConnect.Data.Market.BaseContract, QuantConnect.Securities.Security], t_2_param: datetime.datetime) -> QuantConnect.Symbol:
...

@overload
def test_method_3(self, t_1_param: typing.Union[QuantConnect.Symbol, str, QuantConnect.Data.Market.BaseContract, QuantConnect.Securities.Security], t_2_param: typing.List[System.Collections.Generic.Dictionary[QuantConnect.Symbol, typing.List[datetime.datetime]]]) -> typing.List[System.Collections.Generic.Dictionary[QuantConnect.Symbol, datetime.datetime]]:
...

@overload
def test_method_3(self,number:int,time:typing.Union[datetime.datetime,datetime.date]) -> None:
...
"
}).SetName("GeneratesMethodsWithSymbolImplicitConversionForInheritedGenericClasses"),

Expand Down
8 changes: 4 additions & 4 deletions QuantConnectStubsGenerator/Model/PythonType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ namespace QuantConnectStubsGenerator.Model
{
public class PythonType : IEquatable<PythonType>
{
public static readonly PythonType Security = new("Security", "QuantConnect.Securities");
public static readonly PythonType SymbolType = new PythonType("Symbol", "QuantConnect");
public static readonly PythonType ImplicitConversionParameterSymbolType =
CreateUnion(SymbolType, new PythonType("str"), new PythonType("BaseContract", "QuantConnect.Data.Market"),
new PythonType("Security", "QuantConnect.Securities"));
CreateUnion(SymbolType, new PythonType("str"), new PythonType("BaseContract", "QuantConnect.Data.Market"), Security);

public static readonly PythonType Any = new PythonType("Any", "typing");
public static readonly PythonType None = new PythonType("None");
public static readonly PythonType Any = new("Any", "typing");
public static readonly PythonType None = new("None");

public string Name { get; set; }
public string Namespace { get; set; }
Expand Down
5 changes: 4 additions & 1 deletion QuantConnectStubsGenerator/Renderer/ClassRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ private void RenderMethods(Class cls)
.OrderBy(m => m.Name)
.ThenBy(m => m.DeprecationReason == null ? 0 : 1)
// pyobjects are converted into typing.any, we want those at the top so they resolve first which is what actually happens
.ThenBy(m => m.Parameters.Any(x => x.Type.Name.Equals("Any")) ? 0 : 1);
.ThenBy(m => m.HasPyObjectParameter
// a security is actually an any so it will match much lighter, so we place security methods before
? 0 : m.Parameters.Any(x => x.Type.Name.Equals(PythonType.Security.Name) || x.Type.TypeParameters.Any(y => y.Name.Equals(PythonType.Security.Name)))
? 1 : 2);

foreach (var method in orderedMethods)
{
Expand Down
Loading