diff --git a/spacy/cli/__init__.py b/spacy/cli/__init__.py index 8aea6ef45..4c3adc5d3 100644 --- a/spacy/cli/__init__.py +++ b/spacy/cli/__init__.py @@ -21,8 +21,8 @@ from .project.clone import project_clone # noqa: F401 from .project.assets import project_assets # noqa: F401 from .project.run import project_run # noqa: F401 from .project.dvc import project_update_dvc # noqa: F401 -from .project.push import project_push # noqa: F401 -from .project.pull import project_pull # noqa: F401 +from .project.push import project_push # noqa: F401 +from .project.pull import project_pull # noqa: F401 @app.command("link", no_args_is_help=True, deprecated=True, hidden=True) diff --git a/spacy/cli/train.py b/spacy/cli/train.py index 1366e0b38..15188cd4e 100644 --- a/spacy/cli/train.py +++ b/spacy/cli/train.py @@ -75,7 +75,9 @@ def train( msg.info("Using CPU") msg.info(f"Loading config and nlp from: {config_path}") with show_validation_error(config_path): - config = util.load_config(config_path, overrides=config_overrides, interpolate=True) + config = util.load_config( + config_path, overrides=config_overrides, interpolate=True + ) if config.get("training", {}).get("seed") is not None: fix_random_seed(config["training"]["seed"]) # Use original config here before it's resolved to functions @@ -208,7 +210,9 @@ def create_evaluation_callback( scores = nlp.evaluate(dev_examples) # Calculate a weighted sum based on score_weights for the main score try: - weighted_score = sum(scores.get(s, 0.0) * weights.get(s, 0.0) for s in weights) + weighted_score = sum( + scores.get(s, 0.0) * weights.get(s, 0.0) for s in weights + ) except KeyError as e: keys = list(scores.keys()) err = Errors.E983.format(dict="score_weights", key=str(e), keys=keys) @@ -378,7 +382,8 @@ def setup_printer( try: scores = [ - "{0:.2f}".format(float(info["other_scores"].get(col, 0.0))) for col in score_cols + "{0:.2f}".format(float(info["other_scores"].get(col, 0.0))) + for col in score_cols ] except KeyError as e: raise KeyError( diff --git a/spacy/language.py b/spacy/language.py index 6fc780f3e..57abcca0e 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -774,7 +774,13 @@ class Language: # we have no components to insert before/after, or we're replacing the last component self.add_pipe(factory_name, name=name, config=config, validate=validate) else: - self.add_pipe(factory_name, name=name, before=pipe_index, config=config, validate=validate) + self.add_pipe( + factory_name, + name=name, + before=pipe_index, + config=config, + validate=validate, + ) def rename_pipe(self, old_name: str, new_name: str) -> None: """Rename a pipeline component. diff --git a/spacy/ml/models/entity_linker.py b/spacy/ml/models/entity_linker.py index 55d8614e1..6792f3e59 100644 --- a/spacy/ml/models/entity_linker.py +++ b/spacy/ml/models/entity_linker.py @@ -30,6 +30,7 @@ def load_kb(kb_path: str) -> Callable[[Vocab], KnowledgeBase]: kb = KnowledgeBase(vocab, entity_vector_length=1) kb.from_disk(kb_path) return kb + return kb_from_file @@ -37,6 +38,7 @@ def load_kb(kb_path: str) -> Callable[[Vocab], KnowledgeBase]: def empty_kb(entity_vector_length: int) -> Callable[[Vocab], KnowledgeBase]: def empty_kb_factory(vocab): return KnowledgeBase(vocab=vocab, entity_vector_length=entity_vector_length) + return empty_kb_factory diff --git a/spacy/tests/regression/test_issue5230.py b/spacy/tests/regression/test_issue5230.py index 58d03ca8b..2ac886625 100644 --- a/spacy/tests/regression/test_issue5230.py +++ b/spacy/tests/regression/test_issue5230.py @@ -76,6 +76,7 @@ def entity_linker(): kb = KnowledgeBase(vocab, entity_vector_length=1) kb.add_entity("test", 0.0, zeros((1, 1), dtype="f")) return kb + return create_kb config = {"kb_loader": {"@assets": "TestIssue5230KB.v1"}}