Skip to content

Commit

Permalink
CLI: reject module_paths that smell like FS paths
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Dec 22, 2017
1 parent 4ead714 commit ebe5aad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions monkeytype/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import argparse
import importlib
import inspect
import os
import os.path
import runpy
import subprocess
Expand Down Expand Up @@ -41,6 +42,11 @@ def module_path(path: str) -> Tuple[str, Optional[str]]:
parts = path.split(':', 1)
module = parts.pop(0)
qualname = parts[0] if parts else None
if os.sep in module: # Smells like a path
raise argparse.ArgumentTypeError(
f'{module} does not look like a valid Python import path'
)

return module, qualname


Expand Down

0 comments on commit ebe5aad

Please sign in to comment.