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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes file types from .pre-commit-config.yaml issue #744

Closed
wants to merge 2 commits into from

Commits on May 3, 2018

  1. Add tests for _filter_by_types

    Adds a test for python and bash `types` using identify per interpreter
    interpretation.
    
    The python test succeeds with a false positive. The bash test identifies
    the bug, where a comparison happens between `tags >= types`.
    
    Tags is the tag list from identify, types is the value passed in from
    configuration file as `acceptable types`.
    
    The `tags(List) >= types(FrozenSet)` does a sort comparison of the two sequences
    as evidenced by this code sample (which should return True):
    
    ```
    >>> types = frozenset(['a'])
    >>> tags = ['bash']
    >>> tags >= types
    True
    ```
    
    Note: In 2.7, I cannot get this to return anything other than True.
    Including the empty case:
    ```
    >>> [] > frozenset()
    True
    ```
    
    Which means to me that a list is always >= a frozenset in Python 2.7.
    
    In Python 3.5, I see errors when comparing a List to a FrozenSet. So
    thankfully the interpreter is stricter in this case.
    
    ```
    >>> [] >= frozenset()
    TypeError: unorderable types: list() >= frozenset()
    ```
    zph committed May 3, 2018
    Configuration menu
    Copy the full SHA
    29d66f4 View commit details
    Browse the repository at this point in the history
  2. Fix types bug by using FrozenSet#intersection

    Fixes a bug where files are not being recognized based on their `types`
    using configuration file.
    
    In the case of using `types: ['bash', 'sh', 'shell']` in
    pre-commit-config, those filetypes will not be found, resulting in "no
    files found" being reported with pre-commit. This persists even when
    using --all-files flag.
    
    Intersection produces predictable results in Python 2.7 and 3.x.
    zph committed May 3, 2018
    Configuration menu
    Copy the full SHA
    ff66c20 View commit details
    Browse the repository at this point in the history