Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.

Fix: select_subclass now supports dotted class names (Fixes #56)#169

Open
RajT393 wants to merge 1 commit into
facebookincubator:mainfrom
RajT393:main
Open

Fix: select_subclass now supports dotted class names (Fixes #56)#169
RajT393 wants to merge 1 commit into
facebookincubator:mainfrom
RajT393:main

Conversation

@RajT393

@RajT393 RajT393 commented Aug 1, 2025

Copy link
Copy Markdown

📝 Summary

This pull request fixes Issue #56 by updating the select_subclass() selector to correctly match class definitions that inherit from dotted base class names (e.g., module.BaseClass), which were previously ignored.


🐞 Problem

The select_subclass() selector in bowler/query.py only supported simple base class names like BaseClass.
It failed to match subclasses that inherit from dotted names such as module.BaseClass, because it didn’t traverse ast.Attribute nodes in the AST.


✅ Fix

The function has been enhanced to:

  • Handle both Name and Attribute nodes in the AST
  • Correctly match dotted base class names (e.g., module.BaseClass)

🧪 Changes Made

  • ✅ Updated logic in select_subclass() to walk through Attribute nodes
  • ✅ Added a test in tests/test_query.py to verify subclass matching with dotted base classes
  • ✅ Ensured all existing tests pass (pytest ran successfully)

🔍 Example

Before:

class Derived(module.BaseClass):
    pass
# ❌ Not matched

After:

class Derived(module.BaseClass):
    pass
# ✅ Matched by select_subclass("module.BaseClass")

🔗 Related Issue

Fixes #56

@meta-cla

meta-cla Bot commented Aug 1, 2025

Copy link
Copy Markdown

Hi @RajT393!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Aug 1, 2025
@meta-cla

meta-cla Bot commented Aug 1, 2025

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

1 similar comment
@meta-cla

meta-cla Bot commented Aug 1, 2025

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

CLA Signed Do not delete this pull request or issue due to inactivity.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

select_subclass selector does not select when specified class contains dot

1 participant