Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --diff with stdin #384

Merged
merged 1 commit into from Jan 16, 2016
Merged

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Jan 8, 2016

This fixes the following error with isort --diff -:

Traceback (most recent call last):
  File "…/pyenv/project/bin/isort", line 9, in <module>
    load_entry_point('isort', 'console_scripts', 'isort')()
  File "…/isort/isort/main.py", line 239, in main
    SortImports(file_contents=sys.stdin.read(), write_to_stdout=True, **arguments)
  File "…/isort/isort/isort.py", line 170, in __init__
    self._show_diff(file_contents)
  File "…/isort/isort/isort.py", line 194, in _show_diff
    fromfiledate=str(datetime.fromtimestamp(os.path.getmtime(self.file_path))),
  File "…/pyenv/project/lib/python3.5/genericpath.py", line 55, in getmtime
    return os.stat(filename).st_mtime
FileNotFoundError: [Errno 2] No such file or directory: ''

This fixes the following error with `isort --diff -`:

    Traceback (most recent call last):
      File "…/pyenv/project/bin/isort", line 9, in <module>
        load_entry_point('isort', 'console_scripts', 'isort')()
      File "…/isort/isort/main.py", line 239, in main
        SortImports(file_contents=sys.stdin.read(), write_to_stdout=True, **arguments)
      File "…/isort/isort/isort.py", line 170, in __init__
        self._show_diff(file_contents)
      File "…/isort/isort/isort.py", line 194, in _show_diff
        fromfiledate=str(datetime.fromtimestamp(os.path.getmtime(self.file_path))),
      File "…/pyenv/project/lib/python3.5/genericpath.py", line 55, in getmtime
        return os.stat(filename).st_mtime
    FileNotFoundError: [Errno 2] No such file or directory: ''
@timothycrosley
Copy link
Member

Thanks for resolving this issue!

~Timothy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants