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

Resolve "flake8 does not generate error when given a non-existent file on the command line" - [merged] #878

Closed
asottile opened this issue Apr 3, 2021 · 6 comments

Comments

@asottile
Copy link
Member

asottile commented Apr 3, 2021

In GitLab by @Shukron on Feb 21, 2018, 08:22

Merges 405-nonexisting-files -> master

Closes #405

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @codecov on Feb 21, 2018, 08:22

Codecov Report

Merging #227 into master will increase coverage by 0.41%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #227      +/-   ##
==========================================
+ Coverage   69.97%   70.38%   +0.41%     
==========================================
  Files          27       27              
  Lines        2348     2347       -1     
  Branches      383      383              
==========================================
+ Hits         1643     1652       +9     
+ Misses        632      620      -12     
- Partials       73       75       +2
Impacted Files Coverage Δ
src/flake8/checker.py 47.83% <100%> (+2.6%) ⬆️
src/flake8/processor.py 64.87% <0%> (+0.41%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f834499...59218ca. Read the comment docs.

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @sigmavirus24 on Apr 15, 2018, 12:33

Can you describe the new behaviour in this case? I see that the FileProcessor raises (or doesn't handle) an IOError but what does Flake8 do with that?

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @Shukron on Apr 15, 2018, 13:35

flake8 will catch that IOError and report it as an E902.

The following code is from the FileChecker class, which calls this method in its __init__.

def _make_processor(self):
    try:
        return processor.FileProcessor(self.filename, self.options)
    except IOError:
        # If we can not read the file due to an IOError (e.g., the file
        # does not exist or we do not have the permissions to open it)
        # then we need to format that exception for the user.
        # NOTE(sigmavirus24): Historically, pep8 has always reported this
        # as an E902. We probably *want* a better error code for this
        # going forward.
        (exc_type, exception) = sys.exc_info()[:2]
        message = '{0}: {1}'.format(exc_type.__name__, exception)
        self.report('E902', 0, 0, message)
        return None

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @sigmavirus24 on Apr 15, 2018, 16:33

Ah, perfect. I forgot we had that.

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @sigmavirus24 on Apr 15, 2018, 16:33

merged

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @sigmavirus24 on Apr 15, 2018, 16:33

mentioned in commit 5221014

@asottile asottile closed this as completed Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant