-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable nullable on some modules #1901
Conversation
Great! I was just about starting to do the same… |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Gets rid of
ø
fromparams
andParamDictionary
arguments. There are still a couple\u00F8
left over in other arguments. Not sure if they're necessary or not...
Strange that there are some \u00F8
in some other arguments. We would probably have to look at those instances case by case (if somebody has the patience).
I would suggest to further standardize the parameter names to args
and kwargs
, since these are Python names by convention and they do show up in generated signatures by help(...)
. I see in some places kwArgs
(.NET camelCase) or otherArgs
(???)
Remove
NotNone
fromParamDictionary
arguments since it's nevernull
.Add
NotNone
to allparams
arguments. Not having this can result in anull
instead of the empty array. There seem to be some cases where this isn't necessary but I haven't quite figure out the logic so I'm just putting it everywhere (with the help of an analyzer).
The odd behaviour is most likely because IronLanguages/dlr#249 is not finished yet — only the prohibition by keyword part is done. The prohibition by position is not, but the goal is that ParamDictionary
is prohibited by position as well, while params
array is allowed (this is only partly implemented). So the rules you put in the Analyzer are ultimately correct (for IronPython, at least).
The logic for params
array is (or is supposed to be) that without [NotNone]
, when None
is passed, then args
is null
(classic binding by position). With [NotNone]
, args
becomes [null]
(an array with 1 element of value null
). The reason for supporting binding by position is that it matches C#, and IPY needs to be able to call .NET API like C# can.
I am a bit surprised that ParamDictionary
never binds by position (hence is never null), perhaps I implemented more than I remember now. Or perhaps there are still some corner cases when it is possible (like multiple overloads with various number of parameters combined with optionals).
// PerformModuleReload is special and we don't need NotNone annotations | ||
if (methodSymbol.Name == "PerformModuleReload") return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose PerformModuleReload
is special only if it has SpecialMethodAttribute
? Although I haven't seen any non-special ones around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can tell SpecialMethodAttribute
doesn't affect anything. 🤷
It's not too bad, count is down to 35 lines after this PR. Some of them seem "legit" like
Sure, I can look at that.
I did double check this with a simple I think it's when we have both a |
Haha, I just wrote that I would look at it then clicked on merge. 🤦 I've got more analyzer tweaks coming up so will include it in that... |
Add nullable annotations on some modules.
Other notable changes:
PerformModuleReload
from the analyzer so we don't need topragma disable
it.ø
fromparams
andParamDictionary
arguments. There are still a couple\u00F8
left over in other arguments. Not sure if they're necessary or not...NotNone
fromParamDictionary
arguments since it's nevernull
.NotNone
to allparams
arguments. Not having this can result in anull
instead of the empty array. There seem to be some cases where this isn't necessary but I haven't quite figure out the logic so I'm just putting it everywhere (with the help of an analyzer).