koodaamo / tnefparse

a TNEF decoding library written in python, without external dependencies
GNU Lesser General Public License v3.0
49 stars 37 forks source link

Apply Flake8 on source code #67

Closed jugmac00 closed 4 years ago

jugmac00 commented 4 years ago

... and enforce it via CI, ie Travis and GitHub Actions.

Some notes This is a huge diff, which is usually no good idea, but almost inevitable for a first time linting.

There is a very thorough test suite for this package - otherwise I would not have done such a massive linting.

Some notable finding I did not change this bare except statement https://github.com/koodaamo/tnefparse/blob/491ec5b4504b9e7479e9152fa4b641fd27387c60/tnefparse/util.py#L46-L52 as in Python 2 one could expect a ValueError, whereas in Python 3 there can be OverFlowError or OsError - let's fix that when Python 2.7 gets dropped. Also, the except branch is not covered. https://docs.python.org/3/library/datetime.html#datetime.datetime.utcfromtimestamp

I did not touch the unused import statements in the package's __init__.py file, as this may be seen as a public API https://github.com/koodaamo/tnefparse/blob/491ec5b4504b9e7479e9152fa4b641fd27387c60/tnefparse/__init__.py#L3

The many # noqa comments are not excactly beautiful, but... there is not much of a choice https://github.com/koodaamo/tnefparse/blob/491ec5b4504b9e7479e9152fa4b641fd27387c60/tnefparse/mapi.py#L28-L44

The drop in coverage comes from splitting uncovered lines into two, e.g.

attr_data = data[offset : offset + 16]; offset += 16

This fixes #66

codecov[bot] commented 4 years ago

Codecov Report

Merging #67 into master will decrease coverage by 0.00%. The diff coverage is 92.06%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #67      +/-   ##
==========================================
- Coverage   92.98%   92.98%   -0.01%     
==========================================
  Files           7        7              
  Lines        1297     1311      +14     
  Branches      121      121              
==========================================
+ Hits         1206     1219      +13     
- Misses         69       70       +1     
  Partials       22       22              
Impacted Files Coverage Δ
tnefparse/properties.py 100.00% <ø> (ø)
tnefparse/util.py 72.22% <40.00%> (ø)
tnefparse/mapi.py 80.35% <96.00%> (+1.13%) :arrow_up:
tnefparse/__init__.py 71.42% <100.00%> (ø)
tnefparse/codepage.py 80.00% <100.00%> (ø)
tnefparse/tnef.py 92.06% <100.00%> (ø)

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 6a02c0b...491ec5b. Read the comment docs.