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

Changed period into abstract class and moved docstrings #25

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

cardinalion
Copy link
Contributor

No description provided.

Copy link
Owner

@pylipp pylipp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do me a favor, and replace all occurences of 'element' by 'entry'? It's a remainder from the tinydb implementation.
Also, can you check why the travis build failed? You can install the dev tools locally, and run code and style tests yourself (described in 'Contributions' in the README).

:raise: PeriodException if validation failed or table name unknown
:return: ID of new entry (int)
"""
pass
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove all the pass. Having a docstring alone already is a syntactically valid way to define a class.

@cardinalion
Copy link
Contributor Author

Already passed the pre-commit test. Not sure why the build failed

@pylipp
Copy link
Owner

pylipp commented Oct 11, 2019

Did you have a look at the build log? You can do so by clicking 'Details'.

@cardinalion
Copy link
Contributor Author

cardinalion commented Oct 11, 2019

Did you have a look at the build log? You can do so by clicking 'Details'.

TypeError: Can't instantiate abstract class Period with abstract methods add_entry, get_entries, get_entry, remove_entry, update_entry

def test_default_name(self):
        period = Period()
        year = dt.date.today().year
        self.assertEqual(period.year, year)
        self.assertEqual(period.name, str(year))

I'm not sure how to test an abstract class. Should I delete this function?

@pylipp
Copy link
Owner

pylipp commented Oct 12, 2019

Ah that's tricky. Have a look at this (I found it by googling for 'python test abstract class method'). This means you could do

Period.__abstractmethods__ = set()
period = Period()

@coveralls
Copy link

coveralls commented Oct 12, 2019

Coverage Status

Coverage increased (+0.004%) to 99.577% when pulling c7cea25 on cardinalion:period-new into 50aed57 on pylipp:master.

@pylipp
Copy link
Owner

pylipp commented Oct 12, 2019

Can you rebase this onto master?

@pylipp
Copy link
Owner

pylipp commented Oct 12, 2019

Can you also move the methods _preprocess_entry, _remove_redundant_fields, _validate_entry, and _substitute_none_fields and _convert_fields to Period? (sorry for blowing this up so much :))

@cardinalion
Copy link
Contributor Author

cardinalion commented Oct 12, 2019

Can you also move the methods _preprocess_entry, _remove_redundant_fields, _validate_entry, and _substitute_none_fields and _convert_fields to Period? (sorry for blowing this up so much :))

Do you mean cut and copy these methods into Period class? Should I keep the staticmethod decorators?

@pylipp
Copy link
Owner

pylipp commented Oct 26, 2019

I noticed that the change is still a bit trickier... I'd like to have the methods of Period run validation of passed parameters (e.g. for add_entry()), such that methods in derived Period classes can re-use it via super() - so I'm not merging it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants