docgen: Events catalogue misses helpers and generic base classes
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start in common/core/docgen/events.py and trace _resolve_bind, _resolve_method_accessor, visit_ClassDef, and logger_scopes. Compare the parser against api/integrations/gitlab/views/browse_gitlab.py, then verify that module-level bound-logger helpers and subscripted generic base classes resolve their event calls. Done means the generated catalogue includes both previously missed shapes without warnings for the generic accessor.
Written by the indexing model from the issue text.
Description
The docgen events parser (common/core/docgen/events.py) doesn't pick up logger.info(...) / logger.warning(...) / logger.error(...) calls in two common shapes, so the generated catalogue is incomplete.
Shape 1: module-level bound-logger helper
logger = structlog.get_logger(\"gitlab\")
def _get_bound_logger(config):
return logger.bind(
organisation__id=config.project.organisation_id,
project__id=config.project_id,
)
def do_work(config):
log = _get_bound_logger(config)
log.info(\"webhook.registered\", ...) # ← not picked up
_resolve_bind requires the assignment's RHS to be <known_logger_name>.bind(...) exactly. A call to a module-level helper (_get_bound_logger(config)) has func=ast.Name(\"_get_bound_logger\"), not ast.Attribute(\".bind\"), so the assignment is skipped. The subsequent log.info(...) hits the isinstance(target, ast.Name) branch and logger_scopes.get(\"log\") returns None — silently dropped (no warning because it's not a self.* access).
Workaround: inline log = logger.bind(...) at the top of each emitting function. Loses DRY across functions that share the same bound context.
Shape 2: generic base class providing the accessor
class _BaseView(ListAPIView, Generic[T]):
def _log_for(self, config): return logger.bind(...)
class BrowseIssues(_BaseView[Issue]):
def fetch(self, config):
self._log_for(config).info(\"issues.fetched\", ...) # ← warns, not picked up
visit_ClassDef only inherits from bases that are ast.Name and present in _module_classes:
for base in node.bases:
if isinstance(base, ast.Name) and base.id in self._module_classes:
...
When the base is subscripted (_BaseView[Issue]), the base is ast.Subscript, so inheritance is skipped and _log_for isn't in the subclass's class_scope. Produces a warning but the event doesn't land in the catalogue.
Real example: api/integrations/gitlab/views/browse_gitlab.py — _GitLabListView[GitLabIssue].
Suggested direction
- Shape 1: track module-level functions whose body is a single
return logger.bind(...)the same way_resolve_method_accessortracks class methods, and resolve their call sites. - Shape 2: when a base class is
ast.Subscriptwithvalue=ast.Name(id=...), treat the inner name as the base for inheritance.
- Dominant language
- Python
- Stars
- 2
- Forks
- 4
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 10
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Flagsmith/flagsmith-common
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Flagsmith/flagsmith-common#250 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Flagsmith/flagsmith-common#198 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Flagsmith/flagsmith-common#254 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Flagsmith/flagsmith-common#252 ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
Flagsmith/flagsmith-common#245 ·
All issues in Flagsmith/flagsmith-common
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100