Decide: should the declaration check follow code in a mixin that sets path or default?

Open
#111 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
django, python
Domain
backend

Research direction

Read ADR 0021 Decision 2 and the declaration check, _path_from_module, and import_models paths referenced in the issue. Compare the six reproduced cases and decide how far the check should follow mixin, metaclass, and post-definition behavior. Done means documenting a clear scope decision for which cases the declaration check will reject or leave out of scope.

Written by the indexing model from the issue text.

Description

The closed namespace (ADR 0021 Decision 2) reads the public names a config class and its mixins hold. Code in a mixin can still give a declaring class a path or default it never wrote, and nothing refuses it. This was found while settling #59. Each case below was reproduced on release/0.1.0a2, and each ends with a declaring class that has a snapshot:

  1. A mixin overrides _path_from_module. Private names are admitted, and Django calls that method to derive path.
  2. A mixin defines __getattr__ that answers path, or an __init__ that sets self.path. Django's hasattr(self, "path") then finds it.
  3. A mixin's __init_subclass__ sets cls.path or cls.default after super().__init_subclass__(), so after the check has run.
  4. The same hook sets them before super(), and _check then reads them as written in the declaring class's own body.
  5. path or default is rebound on a mixin after the class is defined. import_models checks only name and label again.
  6. A metaclass property for default on a base class hides the declaring class's own default.

A decision is needed on how far the check should follow code rather than attributes. Possible directions are refusing dunder hooks other than ready in a mixin, refusing a metaclass, and checking path and default in import_models too. Leaving these out of scope is also possible, since each case takes deliberate code.

Dominant language
Python
Stars
1
Forks
0
Avg merge
5h 30m
Merged PRs (30d)
85

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stack314/django-neolith

All issues in stack314/django-neolith

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.