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

[ENH] Add also #735

Merged
merged 18 commits into from Sep 10, 2020
Merged

[ENH] Add also #735

merged 18 commits into from Sep 10, 2020

Conversation

sauln
Copy link
Contributor

@sauln sauln commented Sep 7, 2020

PR Description

Please describe the changes proposed in the pull request:

This PR resolves #731.

PR Checklist

Please ensure that you have done the following:

  1. PR in from a fork off your branch. Do not PR from <your_username>:dev, but rather from <your_username>:<feature-branch_name>.
  1. If you're not on the contributors list, add yourself to AUTHORS.rst.
  1. Add a line to CHANGELOG.rst under the latest version header (i.e. the one that is "on deck") describing the contribution.
    • Do use some discretion here; if there are multiple PRs that are related, keep them in a single line.

Quick Check

To do a very quick check that everything is correct, follow these steps below:

  • Run the command make check from pyjanitor's top-level directory. This will automatically run:
    • black formatting
    • flake8 checking
    • running the test suite
    • docs build

Once done, please check off the check-box above.

If make check does not work for you, you can execute the commands listed in the Makefile individually.

Code Changes

If you are adding code changes, please ensure the following:

  • Ensure that you have added tests.
  • Run all tests ($ pytest .) locally on your machine.
    • Check to ensure that test coverage covers the lines of code that you have added.
    • Ensure that all tests pass.

Documentation Changes

If you are adding documentation changes, please ensure the following:

  • Build the docs locally.
  • View the docs to check that it renders correctly.

Relevant Reviewers

Please tag maintainers to review.

@sauln
Copy link
Contributor Author

sauln commented Sep 7, 2020

Locally, everything passed except the tests with Spark. Also, when I build the docs there is are a ton of changes. Do you want the new files in docs/reference committed?

Copy link
Member

@ericmjl ericmjl left a comment

Choose a reason for hiding this comment

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

Very thoughtful setup on the tests, @sauln! Thanks for the effort put in 😄. I'm only requesting some changes regarding docstrings.

The spark tests might fail locally, but that shouldn't worry you. As long as they don't fail on the CI, which is the ultimate arbiter of whether the tests passed or not, that's cool with me.

Speaking of the CI, it was flake8 that was failing. Some of my suggestions below should help.

Other than that, it's just adding docstrings to the tests. I noticed I had trouble deciphering some tests that others had submitted, so I've started asking for docstrings on tests. (Hynek Schwalak has a great blog post on this.) Please modify my suggestions if they're phrased incorrectly!

tests/functions/test_also.py Show resolved Hide resolved
tests/functions/test_also.py Show resolved Hide resolved
tests/functions/test_also.py Outdated Show resolved Hide resolved
tests/functions/test_also.py Show resolved Hide resolved
tests/functions/test_also.py Show resolved Hide resolved
tests/functions/test_also.py Show resolved Hide resolved
tests/functions/test_also.py Outdated Show resolved Hide resolved
tests/functions/test_also.py Show resolved Hide resolved
tests/functions/test_also.py Show resolved Hide resolved
janitor/functions.py Outdated Show resolved Hide resolved
@ericmjl
Copy link
Member

ericmjl commented Sep 7, 2020

@sauln I just realized I forgot to respond to one of your questions:

Also, when I build the docs there is are a ton of changes. Do you want the new files in docs/reference committed?

No need to worry about these files, as they are built automatically on readthedocs and for the backup deploy to github pages!

Copy link
Member

@ericmjl ericmjl left a comment

Choose a reason for hiding this comment

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

Everything else looks great. Thanks @sauln!

tests/functions/test_also.py Outdated Show resolved Hide resolved
@sauln
Copy link
Contributor Author

sauln commented Sep 7, 2020

Awesome! Thank you @ericmjl for the thorough feedback and interest in this new feature :D I'm excited to make use of it in my own day-to-day.

@sauln
Copy link
Contributor Author

sauln commented Sep 7, 2020

Alright, it looked like I was using some features of unittest only available in Python 3.8.. I've reworked the tests with mocks to reflect the 3.6 API (https://docs.python.org/3.6/library/unittest.mock.html#calls-as-tuples).

@ericmjl it looks like DeepSource doesn't like the tuple unpacking the Python docs recommend. Is this something we can silence, or would you rather I rework it to avoid the bug risk?

@codecov
Copy link

codecov bot commented Sep 7, 2020

Codecov Report

Merging #735 into dev will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##              dev     #735   +/-   ##
=======================================
  Coverage   93.53%   93.53%           
=======================================
  Files          17       17           
  Lines         634      634           
=======================================
  Hits          593      593           
  Misses         41       41           

@ericmjl
Copy link
Member

ericmjl commented Sep 7, 2020

@sauln hmm, I thought that the tuple unpacking inside the tests would be fine. Is there a way to rework those lines such that the bug risk is removed? If not, don't fret it, just add the skipcq: piece on those lines.

@ericmjl
Copy link
Member

ericmjl commented Sep 10, 2020

@sauln thanks for the changes! I’m going to invite review from at least one more core dev before we merge (or wait 2 days, whichever is earlier). This prevents the situation where only one person, i.e. myself, knows what’s going on in the codebase.

@sauln
Copy link
Contributor Author

sauln commented Sep 10, 2020

Sweet, thank you!

@ericmjl ericmjl merged commit 2bd3a20 into pyjanitor-devs:dev Sep 10, 2020
@sauln sauln deleted the saul/731/add-also branch September 10, 2020 23:59
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.

Add an also method akin to Kotlins also
3 participants