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

Feature Request: Option to ignore nested functions #11

Closed
1 of 2 tasks
torfsen opened this issue May 5, 2020 · 5 comments
Closed
1 of 2 tasks

Feature Request: Option to ignore nested functions #11

torfsen opened this issue May 5, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@torfsen
Copy link

torfsen commented May 5, 2020

Is this a BUG REPORT or FEATURE REQUEST?:

  • bug
  • feature

Description of Bug or Feature

Nested functions (i.e. function definitions within function definitions) are usually small helpers that need no docstring and are not part of the public API. It should therefore be possible to optionally ignore them.

@econchick
Copy link
Owner

Thanks for the request! Would the -r/--ignore-regex help in this case? For instance:

# sample.py
"""Sample module-level docs"""

def top_level_func():
    """A top level function"""

    def inner_func():
        pass
$ interrogate -r inner_func tests/functional/sample/full.py -vv

=== Coverage for /Users/lynn/dev/interrogate/tests/functional/sample/ ====
--------------------------- Detailed Coverage ----------------------------
| Name                                      |                     Status |
|-------------------------------------------|----------------------------|
| full.py (module)                          |                    COVERED |
|   top_level_func (L5)                     |                    COVERED |
|-------------------------------------------|----------------------------|

-------------------------------- Summary ---------------------------------
| Name           |       Total |       Miss |       Cover |       Cover% |
|----------------|-------------|------------|-------------|--------------|
| full.py        |           2 |          0 |           2 |         100% |
|----------------|-------------|------------|-------------|--------------|
| TOTAL          |           2 |          0 |           2 |       100.0% |
------------ RESULT: PASSED (minimum: 80.0%, actual: 100.0%) -------------

@torfsen
Copy link
Author

torfsen commented May 5, 2020

Would the -r/--ignore-regex help in this case?

In theory, yes -- but that would require me to hardcode all of the inner functions, since they usually don't follow any systematic naming scheme. That's something I'd like to avoid when working on a larger code base. Ignoring the nested functions completely (just like, say, magic functions) would be much easier.

It's not something that's a deal breaker for me, but it would be a welcome addition.

@econchick
Copy link
Owner

Ah, understood - I'll see if I can figure something out. Thanks for the idea!

@econchick econchick added the enhancement New feature or request label May 6, 2020
econchick added a commit that referenced this issue May 13, 2020
Addresses feature request #11
@econchick
Copy link
Owner

Hey @torfsen - I've added this feature for ya in #24 via a new flag: -n / --ignore-nested-functions. It will be released in v1.2.0, but I want to try and address your other feature request before actually making that release. Feel free to try it out before then via

pip install git+https://github.com/econchick/interrogate.git@cd06c57b91cf8adf6fe692d310cdb1cb4afb1640

I'll update this issue once it is released on PyPI either way.

@econchick
Copy link
Owner

I've released 1.2.0 with this feature included - thank you for the suggestion!

Digitalintf added a commit to Digitalintf/interrogate that referenced this issue Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants