From e0e3e9653b9b0ff9e571a82212a79b6df5ef63e7 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 20 Sep 2021 15:52:02 +0200 Subject: [PATCH] Revert "raise E983 early on in docbin init" This reverts commit f3f7afa21f05b19f84f2bc1692253f5b8ff5410a. --- spacy/errors.py | 2 +- spacy/tokens/_serialize.py | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/spacy/errors.py b/spacy/errors.py index d1b33b1c9..a206826ff 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -792,7 +792,7 @@ class Errors: "to token boundaries.") E982 = ("The `Token.ent_iob` attribute should be an integer indexing " "into {values}, but found {value}.") - E983 = ("Invalid key(s) for '{dict}': {key}. Available keys: " + E983 = ("Invalid key for '{dict}': {key}. Available keys: " "{keys}") E984 = ("Invalid component config for '{name}': component block needs either " "a key `factory` specifying the registered function used to " diff --git a/spacy/tokens/_serialize.py b/spacy/tokens/_serialize.py index 064885b3b..868eb3eab 100644 --- a/spacy/tokens/_serialize.py +++ b/spacy/tokens/_serialize.py @@ -8,7 +8,7 @@ from thinc.api import NumpyOps from .doc import Doc from ..vocab import Vocab from ..compat import copy_reg -from ..attrs import SPACY, ORTH, intify_attr, IDS +from ..attrs import SPACY, ORTH, intify_attr from ..errors import Errors from ..util import ensure_path, SimpleFrozenList @@ -64,11 +64,7 @@ class DocBin: DOCS: https://spacy.io/api/docbin#init """ - try: - attrs = sorted([intify_attr(attr) for attr in attrs]) - except TypeError: - non_valid = [attr for attr in attrs if intify_attr(attr) is None] - raise KeyError(Errors.E983.format(dict="attrs", key=non_valid, keys=IDS.keys())) from None + attrs = sorted([intify_attr(attr) for attr in attrs]) self.version = "0.1" self.attrs = [attr for attr in attrs if attr != ORTH and attr != SPACY] self.attrs.insert(0, ORTH) # Ensure ORTH is always attrs[0]