Skip to content

Bug: reader_python misidentifies nested functions #2276

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

Open
thseiler opened this issue May 27, 2025 · 0 comments
Open

Bug: reader_python misidentifies nested functions #2276

thseiler opened this issue May 27, 2025 · 0 comments

Comments

@thseiler
Copy link
Contributor

Describe the bug

When parsing Python source files, StrictDoc's Python reader incorrectly extracts nested function names as class-level method names.

To Reproduce

  1. Define a class with nested methods
class Foo:
        
    def sort_by_name(people):
        def key_func(person):
            """@relation(REQ-1, scope=function)"""
            return person["name"].lower()
        return sorted(people, key=key_func)

    def sort_by_age(people):
        def key_func(person):
            """@relation(REQ-2, scope=function)"""
            return person["age"]
        return sorted(people, key=key_func)
  1. complete the example to get a full StrictDoc Project:
[project]

features = [
  "REQUIREMENT_TO_SOURCE_TRACEABILITY",
  "SOURCE_FILE_LANGUAGE_PARSERS",
  "PROJECT_STATISTICS_SCREEN"
]
[DOCUMENT]
TITLE: Decorated Method Test

[REQUIREMENT]
UID: REQ-1
TITLE: Requirement Title
STATEMENT: Requirement Statement

[REQUIREMENT]
UID: REQ-2
TITLE: Requirement Title
STATEMENT: Requirement Statement
  1. Run StrictDoc

strictdoc server .

the extracted name is function Foo.key_func()

Expected behavior

the extracted name should be function Foo.sort_by_name.key_func()

Screenshots

Image

Environment

OS: Windows 11
Browser: MS Edge 136.0.3240.76
StrictDoc: 0.8.0

Additional context

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

No branches or pull requests

1 participant