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

Issue15 - implement pre commit flake8 #16

Draft
wants to merge 9 commits into
base: 11-implement-pypi-jc
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,notebooks
max-line-length = 119
max-complexity = 18
;ignore = E203, E266, E501, W503, F403, F401
;select = B,C,E,F,W,T4,B9
2 changes: 1 addition & 1 deletion .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Flake8

on:
on:
push:
paths:
- 'src/lss/**'
Expand Down
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0 # Use the ref you want to point at
hooks:
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: trailing-whitespace
- id: flake8
# - repo: https://github.com/ambv/black
# rev: stable
# hooks:
# - id: black
# language_version: python3.6
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
pre-commit
flake8

pytest

astunparse==1.6.2
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setuptools.setup(
name="lsseq-jc",
version=__version__, # noqa: E731
version=__version__, # noqa: F821

author="Johnny Cochrane",
author_email="johnny.p.cochrane@gmail.com",
Expand Down
2 changes: 0 additions & 2 deletions src/lss/dataclass/item.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@


import os
import logging

from typing import List
Expand Down
10 changes: 6 additions & 4 deletions src/lss/dataclass/sequence.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


from typing import List, Tuple
from typing import Tuple

from dataclasses import dataclass

Expand Down Expand Up @@ -59,9 +59,9 @@ def printf(self) -> str:
return f'%0{self.pad_len}d'


# TODO: Sequence behavior should be split into separate class, however,
# with dataclass inheritance would get `TypeError: non-default argument 'fileobj' follows default argument`
# https://stackoverflow.com/questions/51575931/class-inheritance-in-python-3-7-dataclasses
# TODO: Sequence behavior should be split into separate class, however, with dataclass inheritance,
# would get `TypeError: non-default argument 'fileobj' follows default argument`
# https://stackoverflow.com/questions/51575931/class-inheritance-in-python-3-7-dataclasses

# TODO: should be able to instantiate this class with a string...
@dataclass
Expand All @@ -87,3 +87,5 @@ class FileSequence:
@property
def is_sequence(self) -> bool:
return len(self.frames) > 1

# TODO: Add wrapper properties: prefix, suffix - str_parts.prefix etc
15 changes: 11 additions & 4 deletions src/lss/lsseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def build_sequences_form1(filepaths: str) -> List[FileSequenceBuilder]:
return sequences_f1


def build_sequences_concrete(sequences_f1: Iterable[FileSequenceBuilder]) -> Generator[FileSequenceBuilder, None, None]:
def build_sequences_concrete(sequences_f1: Iterable[FileSequenceBuilder]) -> Generator[FileSequenceBuilder, None, None]: # noqa: E501

for seq_f1 in sequences_f1:

Expand Down Expand Up @@ -76,9 +76,16 @@ def get_sequences(file_paths: Iterable[str]) -> Generator[FileSequence, None, No
Process a list of filenames to be collected into their

Examples:
>>> files = ['f01.rgb', 'f02.rgb','f03.rgb',]
>>> list(get_sequences(files))
[FileSequence(str_parts=SequenceStrParts(prefix='f', suffix='.rgb', pad_len=2, pad_char='#'), fileobj=Fileobj(dirname='.', ext='.rgb'), frames=(1, 2, 3))]
>>> files = ['file01.rgb', 'file02.rgb','file03.rgb',]
>>> seq = list(get_sequences(files))
>>> len(seq)
1
>>> seq[0].frames
(1, 2, 3)
>>> print(seq[0].str_parts.prefix)
file
>>> print(seq[0].str_parts.suffix)
.rgb

:param file_paths:
:return:
Expand Down
4 changes: 2 additions & 2 deletions src/lss/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def find_matching_frame_substrings(

log.debug(r'diff_results: {diff_results}')

# If more than one substring match is found, we consider this result to be
# invalid for our purposes of finding the substring representing
# If more than one substring match is found, we consider this result to be
# invalid for our purposes of finding the substring representing
# a frame sequence
if not diff_results or len(diff_results) > 1:
return None
Expand Down
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import os
import sys
import doctest

import lss.lsseq

Expand Down Expand Up @@ -33,4 +32,5 @@ def main():
else:
print('Not a directory', dir_path)


sys.exit(main())
1 change: 0 additions & 1 deletion tests/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import sys
import unittest
import doctest

if __name__ == '__main__':

Expand Down