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

Dataframe column names autocompletion #223

Merged
merged 1 commit into from Jul 2, 2020

Conversation

leonardbinet
Copy link
Contributor

@leonardbinet leonardbinet commented Jul 1, 2020

Closes #222

@elasticmachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@cla-checker-service
Copy link

cla-checker-service bot commented Jul 1, 2020

💚 CLA has been signed

Copy link
Contributor

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

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

Thanks for this change! Definitely will be appreciated by users :)
A couple of comments:

  • The CLA service is reporting you haven't signed the CLA, if you have let me know cuz sometimes it's slow and needs a kick to register.
  • You should run nox -s blacken to automatically format and lint your code
  • GitHub tip: if you write "Closes #" then that issue will be automatically closed once this PR is closed. I edited your comment above to do that.

eland/utils.py Outdated
"""
Ensure the given string can be used as attribute on an object instance.
"""
return isinstance(s, str) and re.search(string=s, pattern=r"^[a-zA-Z_]+[a-zA-Z0-9_]*$") and s.replace('_', '')
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Regex can be changed to ^[a-zA-Z_][a-zA-Z0-9_]*$ to remove the backtracking potential but have same meaning.
  • Even though it's technically "slower" can we change the last condition to be s.replace("_", "") != "" to read better?
    Took me a few seconds to figure out what was being done there. :) Also what is it needed for? __ is a valid attr name (not a good one but eh)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • you're right on regex, the + is actually useless
  • I didn't think __ was a valid attribute name but it is indeed :) so I removed the last condition

"""
Provide autocompletion on field names in interactive environment.
"""
return super(NDFrame, self).__dir__() + [
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intentionally super(NDFrame, self) instead of super().__dir__()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was writing in p2/3 compatible, but indeed unnecessary here since eland is designed for python3

@sethmlarson
Copy link
Contributor

jenkins test this please

@sethmlarson
Copy link
Contributor

jenkins test this please

Copy link
Contributor

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

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

This looks great! 🤩

@sethmlarson sethmlarson merged commit 5d0df75 into elastic:master Jul 2, 2020
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.

(Feature) Dataframe column autocompletion
3 participants