Skip to content

Constructing DocBin with attrs=None or a list doesn't work #5577

Closed
@cuckookernel

Description

@cuckookernel

How to reproduce the behaviour

from spacy.tokens import DocBin

doc_bin = DocBin()

This should work according to the docs, as argument attrs to the constructor allows for None
default value or a list of strings. This, however, throws an exception:

Traceback (most recent call last):
  File "/home/teo/miniconda3/envs/bokeh2/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3331, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-98911ff55469>", line 3, in <module>
    a = DocBin()
  File "/home/teo/miniconda3/envs/bokeh2/lib/python3.7/site-packages/spacy/tokens/_serialize.py", line 56, in __init__
    attrs = sorted(intify_attrs(attrs))
  File "attrs.pyx", line 144, in spacy.attrs.intify_attrs
AttributeError: 'list' object has no attribute 'items'

The error apparently stems from the fact that even though attrs is a list (the empty list in this case),
intify_attrs seems to expect a dictionary.

Your Environment

Info about spaCy

  • spaCy version: 2.2.0

  • Platform: Linux-5.0.0-32-generic-x86_64-with-debian-buster-sid

  • Python version: 3.7.6

  • Environment Information:

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat / docFeature: Doc, Span and Token objectsfeat / serializeFeature: Serialization, saving and loading

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions