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

Add ability to ignore file patterns #68

Open
JohnBloom opened this issue Aug 10, 2016 · 7 comments
Open

Add ability to ignore file patterns #68

JohnBloom opened this issue Aug 10, 2016 · 7 comments

Comments

@JohnBloom
Copy link

Flycheck for python generates temp files for each change done in the file even if the file has not been saved. So my_file.py will generate flycheck_my_file.py. As far as I can tell there is no way to change the path or extension of these files.

This creates a problem with pytest-watch. Whenever I change anything it runs the tests even if I havent saved the file. I would really like it to only run on file save. What would be nice was if --ignore could also ignore files by pattern similar to how .gitignore works. So I could run ptw --ignore flycheck* and not trigger a test when the flycheck files are generated.

Regardless, I am loving this tool. Thanks for developing it.

@TauPan
Copy link

TauPan commented Sep 29, 2016

This hurts me, too. In addition, emacs will create auto-saves and lockfiles in the current directory by default.

@JohnBloom as a workaround, you could try override flycheck for python (I'm using elpy) to use flymake-create-temp-with-folder-structure instead of flymake-create-temp-inplace. I'm using the following, which is quite a mouthful, so a little help from pytest-watch would be much appreciated:

(defun elpy-flymake-python-init ()
  ;; Make sure it's not a remote buffer as flymake would not work
  (when (not (file-remote-p buffer-file-name))
    (let* ((temp-file (flymake-init-create-temp-buffer-copy
                       'flymake-create-temp-with-folder-structure)))
      (list python-check-command
            (list temp-file)
            ;; Run flake8 from / to avoid import problems (#169)
            "/"))))

;;---- from https://www.emacswiki.org/emacs/BackupDirectory
(setq backup-directory-alist
      `((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
      `((".*" ,temporary-file-directory t)))
(message "Deleting old backup files...")
(let ((week (* 60 60 24 7))
      (current (float-time (current-time))))
  (dolist (file (directory-files temporary-file-directory t))
    (when (and (backup-file-name-p file)
               (> (- current (float-time (fifth (file-attributes file))))
                  week))
      (message "%s" file)
      (delete-file file))))
;;----
(setq create-lockfiles nil)
;;----

@Rovanion
Copy link

Sadly, on my machine at least, it seems like the above Emacs config makes flake8 lose track of the .flake8 files in the project structure and thus which rules it should or shouldn't apply.

@freckletonj
Copy link

Emacs lock files endlessly trigger test runs. Autosaves are less frequent but still thorny. It would be nice if pytest-watch could respect .gitignore or custom regex/globs, eg: \#*\# and .\#*.

@kontsaki
Copy link

for linux users as a replacement for pytest-watch you can use the entr command which is an interface to inotify and feed it whatever files you want through fdfind / find etc.

@leotrs
Copy link

leotrs commented Jun 6, 2022

Also having this problem

@KMontag42
Copy link

bump

@space-nuko
Copy link

Also had this problem, with flycheck specifically

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

No branches or pull requests

8 participants