Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
Add flake8

Add Makefile

Style fixes
  • Loading branch information
yakimka committed Feb 10, 2020
1 parent 790f8ae commit ccd77d6
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 42 deletions.
2 changes: 1 addition & 1 deletion CherryTomato/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
MEDIA_DIR = os.path.join(BASE_DIR, 'media')
APP_ICON = os.path.join(MEDIA_DIR, 'icon.png')

VERSION = '0.4.0'
VERSION = '0.4.1'
ORGANIZATION_NAME = 'yakimka'
APPLICATION_NAME = 'CherryTomato'
1 change: 0 additions & 1 deletion CherryTomato/__main__.py

This file was deleted.

2 changes: 1 addition & 1 deletion CherryTomato/about_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PyQt5.QtGui import QIcon

from CherryTomato import APP_ICON, VERSION
from .about_ui import Ui_About
from CherryTomato.about_ui import Ui_About


class About(QtWidgets.QWidget, Ui_About):
Expand Down
18 changes: 12 additions & 6 deletions CherryTomato/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@
from CherryTomato import ORGANIZATION_NAME, APPLICATION_NAME
from CherryTomato.main_window import CherryTomatoMainWindow

QCoreApplication.setOrganizationName(ORGANIZATION_NAME)
QCoreApplication.setApplicationName(APPLICATION_NAME)

app = Qt.QApplication(sys.argv)
def main():
QCoreApplication.setOrganizationName(ORGANIZATION_NAME)
QCoreApplication.setApplicationName(APPLICATION_NAME)

watch = CherryTomatoMainWindow()
watch.show()
app = Qt.QApplication(sys.argv)

app.exec_()
watch = CherryTomatoMainWindow()
watch.show()

app.exec_()


if __name__ == '__main__':
main()
8 changes: 6 additions & 2 deletions CherryTomato/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def autoStopBreak(self, val):

@property
def switchToTomatoOnAbort(self):
return self.settings.value(self.SWITCH_TO_TOMATO_ON_ABORT, self.SWITCH_TO_TOMATO_ON_ABORT_DEFAULT, type=bool)
return self.settings.value(
self.SWITCH_TO_TOMATO_ON_ABORT, self.SWITCH_TO_TOMATO_ON_ABORT_DEFAULT, type=bool
)

@switchToTomatoOnAbort.setter
def switchToTomatoOnAbort(self, val):
Expand Down Expand Up @@ -133,7 +135,9 @@ def stateBreak(self, min):

@property
def stateLongBreak(self):
return self.settings.value(self.STATE_LONG_BREAK, State('long_break', self.LONG_BREAK_DEFAULT))
return self.settings.value(
self.STATE_LONG_BREAK, State('long_break', self.LONG_BREAK_DEFAULT)
)

@stateLongBreak.setter
def stateLongBreak(self, min):
Expand Down
4 changes: 3 additions & 1 deletion CherryTomato/tomato_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def changeState(self):
def _statesGen(self):
while True:
yield self.settings.stateTomato
yield self.settings.stateLongBreak if self._isTimeForLongBreak() else self.settings.stateBreak
longBreak = self.settings.stateLongBreak
break_ = self.settings.stateBreak
yield longBreak if self._isTimeForLongBreak() else break_

def _isTimeForLongBreak(self):
if self.tomatoes == 0:
Expand Down
9 changes: 3 additions & 6 deletions CherryTomato/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,9 @@ def calculateInnerRect(self, outerRadius: float):
secondInnerRect = QRectF(left, top + firstHeight, width, height - firstHeight)
return firstInnerRect, secondInnerRect, innerRadius

def drawTwoTexts(self,
p: QPainter,
firstRect: QRectF,
secondRect: QRectF,
innerRadius: float,
value: float):
def drawTwoTexts(
self, p: QPainter, firstRect: QRectF, secondRect: QRectF, innerRadius: float, value: float
):
if not self.m_format:
return
f = QFont(self.font())
Expand Down
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
all: init clean lint test

clean: clean-build clean-pyc ## Clean build files and pyc files
rm -fr htmlcov/

clean-build: ## Clean build files
rm -fr build/
rm -fr dist/
rm -fr *.egg-info

clean-pyc: ## Clean pyc files
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +

init: ## Install test packages
pip install pytest pytest-qt pytest-mock flake8

test: ## Run tests
pytest

flake: ## Run flake8
flake8 --statistics --count

lint: flake ## Run all linters

.PHONY: help

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

26 changes: 14 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from setuptools import setup

setup(name='CherryTomato',
author='yakimka',
version='0.4.0',
packages=['CherryTomato'],
python_requires='>=3.6',
install_requires=['PyQt5', 'qroundprogressbar'],
url='https://github.com/yakimka/CherryTomato',
license='GPL',
entry_points={'gui_scripts': ['cherry_tomato = CherryTomato.main']},
package_data={
'': ['media/*.*'],
})
from CherryTomato import VERSION

setup(
name='CherryTomato',
author='yakimka',
version=VERSION,
packages=['CherryTomato'],
python_requires='>=3.6',
install_requires=['PyQt5', 'qroundprogressbar'],
url='https://github.com/yakimka/CherryTomato',
license='GPL',
entry_points={'gui_scripts': ['cherry_tomato = CherryTomato.main:main']},
package_data={'': ['media/*.*'], },
)
9 changes: 3 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def value(self, key, default, type=None):

@pytest.fixture
def mock_qsettings(monkeypatch, mocker):
qsettings = mocker.patch('CherryTomato.settings.QSettings', MockQSettings)

monkeypatch.setattr(CherryTomatoSettings, 'TOMATO_DEFAULT', 100)
monkeypatch.setattr(CherryTomatoSettings, 'BREAK_DEFAULT', 25)
monkeypatch.setattr(CherryTomatoSettings, 'LONG_BREAK_DEFAULT', 50)
Expand All @@ -26,13 +24,12 @@ def mock_qsettings(monkeypatch, mocker):
monkeypatch.setattr(CherryTomatoSettings, 'AUTO_STOP_BREAK_DEFAULT', False)
monkeypatch.setattr(CherryTomatoSettings, 'SWITCH_TO_TOMATO_ON_ABORT_DEFAULT', True)

return qsettings
return mocker.patch('CherryTomato.settings.QSettings', MockQSettings)


@pytest.fixture
def settings(mock_qsettings):
settings = CherryTomatoSettings()

return settings
return CherryTomatoSettings()


@pytest.fixture
Expand Down
1 change: 0 additions & 1 deletion tests/ui/test_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ def test_stop_button_with_tomato(mock_main_window, qtbot):
qtbot.mouseClick(mock_main_window.button, QtCore.Qt.LeftButton)

assert mock_main_window.tomatoTimer.running is False

4 changes: 4 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-complexity = 10
max-line-length = 100
exclude = *_ui.py,

0 comments on commit ccd77d6

Please sign in to comment.