Skip to content

Commit

Permalink
Include deleters when ignoring property decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
econchick committed Apr 7, 2024
1 parent 6eee30d commit 5dcb4de
Show file tree
Hide file tree
Showing 28 changed files with 261 additions and 230 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ To view all options available, run ``interrogate --help``:
method` instead.
-P, --ignore-property-decorators
Ignore methods with property setter/getter
Ignore methods with property setter/getter/deleter
decorators. [default: False]
-S, --ignore-setters Ignore methods with property setter
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Added

* `tomli` dependency for Python versions < 3.11, making use of `tomllib` in the standard library with 3.11+ (`#150 <https://github.com/econchick/interrogate/issues/150>`_).

Fixed
^^^^^

* Include support for deleters when ignoring property decorators (`#126 <https://github.com/econchick/interrogate/issues/126>_`).

Removed
^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Command Line Options

.. option:: -P, --ignore-property-decorators

Ignore methods with property setter/getter decorators. [default: ``False``]
Ignore methods with property setter/getter/deleter decorators. [default: ``False``]

.. option:: -S, --ignore-setters

Expand Down
4 changes: 3 additions & 1 deletion src/interrogate/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
is_flag=True,
default=False,
show_default=True,
help="Ignore methods with property setter/getter decorators.",
help="Ignore methods with property setter/getter/deleter decorators.",
)
@click.option(
"-S",
Expand Down Expand Up @@ -313,6 +313,8 @@ def main(ctx, paths, **kwargs):
.. versionchanged:: 1.3.1 only generate badge if results change from
an existing badge.
.. versionchanged:: 1.7.0 include property deleters when ignoring all
property decorators (--ignore-property-decorators)
"""
gen_badge = kwargs["generate_badge"]
if kwargs["badge_format"] is not None and gen_badge is None:
Expand Down
4 changes: 3 additions & 1 deletion src/interrogate/visit.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def _is_ignored_common(self, node):
return False

def _has_property_decorators(self, node):
"""Detect if node has property get/setter decorators."""
"""Detect if node has property get/setter/deleter decorators."""
if not hasattr(node, "decorator_list"):
return False

Expand All @@ -167,6 +167,8 @@ def _has_property_decorators(self, node):
if hasattr(dec, "attr"):
if dec.attr == "setter":
return True
if dec.attr == "deleter":
return True
return False

def _has_setters(self, node):
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/fixtures/expected_badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 28 additions & 26 deletions tests/functional/fixtures/expected_detailed.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@
| Foo.get (L35) | COVERED |
| Foo.prop (L40) | COVERED |
| Foo.prop (L45) | COVERED |
| Foo.module_overload (L50) | COVERED |
| Foo.prop (L50) | COVERED |
| Foo.module_overload (L55) | COVERED |
| Foo.module_overload (L59) | COVERED |
| Foo.simple_overload (L64) | COVERED |
| Foo.module_overload (L60) | COVERED |
| Foo.module_overload (L64) | COVERED |
| Foo.simple_overload (L69) | COVERED |
| Foo.simple_overload (L73) | COVERED |
| top_level_func (L78) | COVERED |
| top_level_func.inner_func (L81) | COVERED |
| Bar (L86) | COVERED |
| Bar.method_bar (L89) | COVERED |
| Bar.method_bar.InnerBar (L92) | COVERED |
| _SemiprivateClass (L98) | COVERED |
| __PrivateClass (L104) | COVERED |
| Foo.simple_overload (L74) | COVERED |
| Foo.simple_overload (L78) | COVERED |
| top_level_func (L83) | COVERED |
| top_level_func.inner_func (L86) | COVERED |
| Bar (L91) | COVERED |
| Bar.method_bar (L94) | COVERED |
| Bar.method_bar.InnerBar (L97) | COVERED |
| _SemiprivateClass (L103) | COVERED |
| __PrivateClass (L109) | COVERED |
|------------------------------------------------------------------|-----------|
| partial.py (module) | COVERED |
| Foo (L8) | COVERED |
Expand All @@ -43,21 +44,22 @@
| Foo.get (L38) | MISSED |
| Foo.a_prop (L42) | MISSED |
| Foo.a_prop (L46) | MISSED |
| Foo.module_overload (L50) | MISSED |
| Foo.module_overload (L53) | MISSED |
| Foo.module_overload (L55) | COVERED |
| Foo.simple_overload (L60) | MISSED |
| Foo.simple_overload (L63) | MISSED |
| Foo.simple_overload (L65) | COVERED |
| documented_top_level_func (L70) | COVERED |
| documented_top_level_func.documented_inner_func (L73) | COVERED |
| undocumented_top_level_func (L78) | MISSED |
| undocumented_top_level_func.undocumented_inner_func (L79) | MISSED |
| Bar (L83) | MISSED |
| Bar.method_bar (L84) | MISSED |
| Bar.method_bar.InnerBar (L85) | MISSED |
| _SemiprivateClass (L89) | MISSED |
| __PrivateClass (L93) | MISSED |
| Foo.a_prop (L50) | COVERED |
| Foo.module_overload (L54) | MISSED |
| Foo.module_overload (L57) | MISSED |
| Foo.module_overload (L59) | COVERED |
| Foo.simple_overload (L64) | MISSED |
| Foo.simple_overload (L67) | MISSED |
| Foo.simple_overload (L69) | COVERED |
| documented_top_level_func (L74) | COVERED |
| documented_top_level_func.documented_inner_func (L77) | COVERED |
| undocumented_top_level_func (L82) | MISSED |
| undocumented_top_level_func.undocumented_inner_func (L83) | MISSED |
| Bar (L87) | MISSED |
| Bar.method_bar (L88) | MISSED |
| Bar.method_bar.InnerBar (L89) | MISSED |
| _SemiprivateClass (L93) | MISSED |
| __PrivateClass (L97) | MISSED |
|------------------------------------------------------------------|-----------|
| child_sample/__init__.py (module) | MISSED |
|------------------------------------------------------------------|-----------|
Expand Down
54 changes: 28 additions & 26 deletions tests/functional/fixtures/expected_detailed_no_module.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@
| Foo.get (L35) | COVERED |
| Foo.prop (L40) | COVERED |
| Foo.prop (L45) | COVERED |
| Foo.module_overload (L50) | COVERED |
| Foo.prop (L50) | COVERED |
| Foo.module_overload (L55) | COVERED |
| Foo.module_overload (L59) | COVERED |
| Foo.simple_overload (L64) | COVERED |
| Foo.module_overload (L60) | COVERED |
| Foo.module_overload (L64) | COVERED |
| Foo.simple_overload (L69) | COVERED |
| Foo.simple_overload (L73) | COVERED |
| top_level_func (L78) | COVERED |
| top_level_func.inner_func (L81) | COVERED |
| Bar (L86) | COVERED |
| Bar.method_bar (L89) | COVERED |
| Bar.method_bar.InnerBar (L92) | COVERED |
| _SemiprivateClass (L98) | COVERED |
| __PrivateClass (L104) | COVERED |
| Foo.simple_overload (L74) | COVERED |
| Foo.simple_overload (L78) | COVERED |
| top_level_func (L83) | COVERED |
| top_level_func.inner_func (L86) | COVERED |
| Bar (L91) | COVERED |
| Bar.method_bar (L94) | COVERED |
| Bar.method_bar.InnerBar (L97) | COVERED |
| _SemiprivateClass (L103) | COVERED |
| __PrivateClass (L109) | COVERED |
|------------------------------------------------------------------|-----------|
| partial.py | |
| Foo (L8) | COVERED |
Expand All @@ -39,21 +40,22 @@
| Foo.get (L38) | MISSED |
| Foo.a_prop (L42) | MISSED |
| Foo.a_prop (L46) | MISSED |
| Foo.module_overload (L50) | MISSED |
| Foo.module_overload (L53) | MISSED |
| Foo.module_overload (L55) | COVERED |
| Foo.simple_overload (L60) | MISSED |
| Foo.simple_overload (L63) | MISSED |
| Foo.simple_overload (L65) | COVERED |
| documented_top_level_func (L70) | COVERED |
| documented_top_level_func.documented_inner_func (L73) | COVERED |
| undocumented_top_level_func (L78) | MISSED |
| undocumented_top_level_func.undocumented_inner_func (L79) | MISSED |
| Bar (L83) | MISSED |
| Bar.method_bar (L84) | MISSED |
| Bar.method_bar.InnerBar (L85) | MISSED |
| _SemiprivateClass (L89) | MISSED |
| __PrivateClass (L93) | MISSED |
| Foo.a_prop (L50) | COVERED |
| Foo.module_overload (L54) | MISSED |
| Foo.module_overload (L57) | MISSED |
| Foo.module_overload (L59) | COVERED |
| Foo.simple_overload (L64) | MISSED |
| Foo.simple_overload (L67) | MISSED |
| Foo.simple_overload (L69) | COVERED |
| documented_top_level_func (L74) | COVERED |
| documented_top_level_func.documented_inner_func (L77) | COVERED |
| undocumented_top_level_func (L82) | MISSED |
| undocumented_top_level_func.undocumented_inner_func (L83) | MISSED |
| Bar (L87) | MISSED |
| Bar.method_bar (L88) | MISSED |
| Bar.method_bar.InnerBar (L89) | MISSED |
| _SemiprivateClass (L93) | MISSED |
| __PrivateClass (L97) | MISSED |
|------------------------------------------------------------------|-----------|
| child_sample/child_sample_module.py | |
| ChildFoo (L5) | MISSED |
Expand Down
27 changes: 14 additions & 13 deletions tests/functional/fixtures/expected_detailed_single_file.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,26 @@
| Foo.get (L35) | COVERED |
| Foo.prop (L40) | COVERED |
| Foo.prop (L45) | COVERED |
| Foo.module_overload (L50) | COVERED |
| Foo.prop (L50) | COVERED |
| Foo.module_overload (L55) | COVERED |
| Foo.module_overload (L59) | COVERED |
| Foo.simple_overload (L64) | COVERED |
| Foo.module_overload (L60) | COVERED |
| Foo.module_overload (L64) | COVERED |
| Foo.simple_overload (L69) | COVERED |
| Foo.simple_overload (L73) | COVERED |
| top_level_func (L78) | COVERED |
| top_level_func.inner_func (L81) | COVERED |
| Bar (L86) | COVERED |
| Bar.method_bar (L89) | COVERED |
| Bar.method_bar.InnerBar (L92) | COVERED |
| _SemiprivateClass (L98) | COVERED |
| __PrivateClass (L104) | COVERED |
| Foo.simple_overload (L74) | COVERED |
| Foo.simple_overload (L78) | COVERED |
| top_level_func (L83) | COVERED |
| top_level_func.inner_func (L86) | COVERED |
| Bar (L91) | COVERED |
| Bar.method_bar (L94) | COVERED |
| Bar.method_bar.InnerBar (L97) | COVERED |
| _SemiprivateClass (L103) | COVERED |
| __PrivateClass (L109) | COVERED |
|-----------------------------------------------------|------------------------|

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

0 comments on commit 5dcb4de

Please sign in to comment.