Skip to content
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

Merged
merged 6 commits into from
Aug 8, 2019
Merged

Conversation

vladmos
Copy link
Member

@vladmos vladmos commented Aug 6, 2019

Replaces legacy keyword arguments with positional arguments in some builtin functions, e.g. bool(x = foo) -> bool(foo).

bazelbuild/bazel#5010

"hasattr": "x",
"getattr": "x",
"select": "x",
}
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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

"hasattr": "x",
"getattr": "x",
"select": "x",
}
Copy link
Contributor

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.

glob(["*.cc"], ["test*"])
native.glob(["*.cc"], ["test*"])
glob(["*.cc"])
native.glob(["*.cc"])
Copy link
Contributor

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)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@laurentlb laurentlb left a 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?

int("13", base = 8)
dir(foo)
type(foo)
hasattr(foo, name = "bar")
Copy link
Contributor

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")

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

dir(foo)
type(foo)
hasattr(foo, name = "bar")
getattr(foo, name = "bar", default = "baz")
Copy link
Contributor

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")

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

glob(["*.cc"])
glob([], exclude = [])
glob([], exclude = [])
glob([], [], 1)
Copy link
Contributor

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)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@laurentlb laurentlb left a comment

Choose a reason for hiding this comment

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

lgtm

@vladmos
Copy link
Member Author

vladmos commented Aug 8, 2019

I'll run it on the existing files right before importing.

@vladmos vladmos merged commit a19f3df into bazelbuild:master Aug 8, 2019
@vladmos vladmos deleted the positional branch August 8, 2019 13:06
cristiancreteanu pushed a commit to cristiancreteanu/buildtools that referenced this pull request Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants