-
Notifications
You must be signed in to change notification settings - Fork 424
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
Fix for legacy named arguments #692
Conversation
warn/warn_bazel_api.go
Outdated
"hasattr": "x", | ||
"getattr": "x", | ||
"select": "x", | ||
} |
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.
How are you going to fix functions with more than 1 argument?
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 was going to implement it in portions, but perhaps I should support flexible amount of arguments now and just add functions/methods later.
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.
You'll have to change the data structure. The current code handles a specific case that never happens in real file (naming the x
argument).
You might as well remove the legacyNamed code and submit only legacyPositional, if you want to split in portions.
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.
Refactored to handle both legacy keyword and legacy positional parameters, even for the same function
warn/warn_bazel_api.go
Outdated
"hasattr": "x", | ||
"getattr": "x", | ||
"select": "x", | ||
} |
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.
You'll have to change the data structure. The current code handles a specific case that never happens in real file (naming the x
argument).
You might as well remove the legacyNamed code and submit only legacyPositional, if you want to split in portions.
warn/warn_bazel_api_test.go
Outdated
glob(["*.cc"], ["test*"]) | ||
native.glob(["*.cc"], ["test*"]) | ||
glob(["*.cc"]) | ||
native.glob(["*.cc"]) |
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.
Add tests:
glob(include = [], exclude = [])
glob([], exclude = [])
glob([], [], 1)
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.
Done.
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.
Can you run it in Google3 and check it's working well?
warn/warn_bazel_api_test.go
Outdated
int("13", base = 8) | ||
dir(foo) | ||
type(foo) | ||
hasattr(foo, name = "bar") |
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.
Should be: hasattr(foo, "bar")
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.
Done.
warn/warn_bazel_api_test.go
Outdated
dir(foo) | ||
type(foo) | ||
hasattr(foo, name = "bar") | ||
getattr(foo, name = "bar", default = "baz") |
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.
Should be:
getattr(foo, "bar", "baz")
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.
Done.
warn/warn_bazel_api_test.go
Outdated
glob(["*.cc"]) | ||
glob([], exclude = []) | ||
glob([], exclude = []) | ||
glob([], [], 1) |
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.
Add exclude_directories:
glob([], exclude = [], exclude_directories = 1)
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.
Done.
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.
lgtm
I'll run it on the existing files right before importing. |
Replaces legacy keyword arguments with positional arguments in some builtin functions, e.g.
bool(x = foo)
->bool(foo)
.bazelbuild/bazel#5010