Giter Site home page Giter Site logo

Comments (6)

Lucas-C avatar Lucas-C commented on June 19, 2024

Could you clarify when you get this error?

The unit tests suite currently passes without any error on my computer and in GitHub Actions.

Is this error caused by PR #33?

from pre-commit-hooks.

mdeweerd avatar mdeweerd commented on June 19, 2024

It's not change related - the master branch fails the same way.

Could be platform related:
"---------- coverage: platform cygwin, python 3.8.12-final-0 ----------"

from pre-commit-hooks.

Lucas-C avatar Lucas-C commented on June 19, 2024

OK, so it only happened in your development environment so far.

Could you indicate on what repository did you get this error? Is it a public GitHub One?
Was it during a git commit?

from pre-commit-hooks.

mdeweerd avatar mdeweerd commented on June 19, 2024

I got it during a git commit (pre-commit) because 'py.test' is effectively executing the tests. I did not get this prior to the first PR as far as I remember.

This just required a small update in test case considering that NotADirectoryError is a suitable exception when trying to open "a/b".

However, I now just think of the following: I often use just 1 letter for temporary files and I created a file name "a' at the root.
After renaming that file the path 'a/b' no longer results in that error type.

I updated a test case to that it trys to access 'README.md/dummy'.
https://github.com/mdeweerd/pre-commit-hooks/blob/9beba6505bc04f9c8015905276efdbf8a46001bb/tests/remove_crlf_test.py#L23 .
The CI is nto running because the pre-commit-config.yaml has not been updated in that branch. But running 'pytest -sv' locally results in:

tests/remove_crlf_test.py:26:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pre_commit_hooks/remove_crlf.py:24: in main
    text_files = [f for f in args.filenames if is_textfile(f)]
pre_commit_hooks/remove_crlf.py:24: in <listcomp>
    text_files = [f for f in args.filenames if is_textfile(f)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

filename = 'README.md/dummy', blocksize = 512

    def is_textfile(filename, blocksize=512):
        if any(filename.endswith(ext) for ext in KNOWN_BINARY_FILE_EXTS):
            return False
>       with open(filename, 'rb') as text_file:
E       NotADirectoryError: [Errno 20] Not a directory: 'README.md/dummy'

pre_commit_hooks/utils.py:8: NotADirectoryError

from pre-commit-hooks.

mdeweerd avatar mdeweerd commented on June 19, 2024

Just though of another type of error: when the file is a directory.
So I added "tests" to the list which provokes a IsADirectoryError (see https://github.com/mdeweerd/pre-commit-hooks/blob/9955842742b90dfb3098b2798cf119f6749f94eb/tests/remove_crlf_test.py#L23 ).

tests/remove_crlf_test.py:26:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pre_commit_hooks/remove_crlf.py:24: in main
    text_files = [f for f in args.filenames if is_textfile(f)]
pre_commit_hooks/remove_crlf.py:24: in <listcomp>
    text_files = [f for f in args.filenames if is_textfile(f)]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

filename = 'tests', blocksize = 512

    def is_textfile(filename, blocksize=512):
        if any(filename.endswith(ext) for ext in KNOWN_BINARY_FILE_EXTS):
            return False
>       with open(filename, 'rb') as text_file:
E       IsADirectoryError: [Errno 21] Is a directory: 'tests'

pre_commit_hooks/utils.py:8: IsADirectoryError

from pre-commit-hooks.

mdeweerd avatar mdeweerd commented on June 19, 2024

I merge from the master branch where you just integrated the changes from #33.
So the CI essentially runs but fails with IsADirectroyError because of 'tests':

https://github.com/mdeweerd/pre-commit-hooks/runs/6366531305?check_suite_focus=true

from pre-commit-hooks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.