From 607eece72a91beb0e9a598a987e51a56bcffb434 Mon Sep 17 00:00:00 2001 From: Matthew Donoughe Date: Thu, 20 Oct 2022 20:18:06 -0400 Subject: [PATCH] move to after check --- scrapy/commands/runspider.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scrapy/commands/runspider.py b/scrapy/commands/runspider.py index a8db1cd86..ed16c3fb6 100644 --- a/scrapy/commands/runspider.py +++ b/scrapy/commands/runspider.py @@ -12,9 +12,9 @@ from scrapy.commands import BaseRunSpiderCommand def _import_file(filepath: Union[str, PathLike]) -> ModuleType: abspath = Path(filepath).resolve() - dirname = str(abspath.parent) if abspath.suffix not in ('.py', '.pyw'): raise ValueError(f"Not a Python source file: {abspath}") + dirname = str(abspath.parent) if dirname: sys.path = [dirname] + sys.path try: