torchbox / torchbox/django-pattern-library

Can't use Python object YAML tags

Open
#155 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
423
Forks
53
PR merge metrics
No merged PRs in 30d

Description

Issue Summary

Use of pyyaml's !!python/object tags to create arbitrary Python objects isn't working. I'm raising this as a bug because it should work, but I'm not sure it's necessarily something we want to support.

Steps to Reproduce

Add a context item like !!python/object:django.forms.fields.CharField, and you get an error like this:

Exception Type: ConstructorError at /pattern-library/pattern/patterns/organisms/form/feedback-form.html
Exception Value: could not determine a constructor for the tag 'tag:yaml.org,2002:python/object:django.forms.fields.CharField'
  in "<unicode string>", line 3, column 5:
        !!python/object:django.forms.fie ... 
        ^

This seems to be related to the use of yaml.FullLoader and our version of pyyaml somehow (ref https://github.com/yaml/pyyaml/issues/266)

Contributor guide

Open the contributing guide

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.

Research direction

Reproduce the failure with a context item using the !!python/object:django.forms.fields.CharField tag, then inspect the yaml.FullLoader and PyYAML version involved. Confirm whether arbitrary Python-object tags are intended to work; completion requires a decided support boundary and either working behavior with regression coverage or clear documentation that the case is unsupported.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.