Skip to content

Commit

Permalink
Merge pull request #73 from klieret/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
klieret committed Apr 30, 2021
2 parents ead8abf + 3fa44ee commit 5cc272e
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 21.4b0
hooks:
- id: black
language_version: python3.7
Expand All @@ -16,7 +16,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/flake8
rev: '3.9.0' # pick a git hash / tag to point to
rev: '3.9.1' # pick a git hash / tag to point to
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
Expand Down
22 changes: 11 additions & 11 deletions ankipandas/ankidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def id(self):

@property
def nid(self):
""" Note ID as :class:`pandas.Series` of integers. """
"""Note ID as :class:`pandas.Series` of integers."""
if self._anki_table == "notes":
return self.index
elif self._anki_table == "cards":
Expand Down Expand Up @@ -257,7 +257,7 @@ def nid(self, value):

@property
def cid(self):
""" Card ID as :class:`pandas.Series` of integers. """
"""Card ID as :class:`pandas.Series` of integers."""
if self._anki_table == "cards":
return self.index
if self._anki_table == "revs":
Expand Down Expand Up @@ -294,7 +294,7 @@ def cid(self, value):

@property
def rid(self):
""" Review ID as :class:`pandas.Series` of integers. """
"""Review ID as :class:`pandas.Series` of integers."""
if self._anki_table == "revs":
return self.index
else:
Expand Down Expand Up @@ -323,7 +323,7 @@ def rid(self, value):

@property
def mid(self):
""" Model ID as :class:`pandas.Series` of integers. """
"""Model ID as :class:`pandas.Series` of integers."""
if self._anki_table in ["notes"]:
if "nmodel" not in self.columns:
raise ValueError(
Expand Down Expand Up @@ -352,7 +352,7 @@ def mid(self, value):

@property
def did(self):
""" Deck ID as :class:`pandas.Series` of integers. """
"""Deck ID as :class:`pandas.Series` of integers."""
if self._anki_table == "cards":
if "cdeck" not in self.columns:
raise ValueError(
Expand Down Expand Up @@ -632,7 +632,7 @@ def _check_tag_col(self):
)

def list_tags(self) -> List[str]:
""" Return sorted list of all tags in the current table. """
"""Return sorted list of all tags in the current table."""
if "ntags" not in self.columns:
raise ValueError(
"Tags column 'ntags' not present. Either use the notes table"
Expand All @@ -644,7 +644,7 @@ def list_tags(self) -> List[str]:
)

def list_decks(self) -> List[str]:
""" Return sorted list of deck names in the current table. """
"""Return sorted list of deck names in the current table."""
if "cdeck" not in self.columns:
raise ValueError(
"Deck column 'cdeck' not present. Either use the cards table "
Expand All @@ -657,7 +657,7 @@ def list_decks(self) -> List[str]:
return decks

def list_models(self):
""" Return sorted list of model names in the current table. """
"""Return sorted list of model names in the current table."""
if "nmodel" not in self.columns:
raise ValueError(
"Model column 'nmodel' not present. Either use the notes table"
Expand Down Expand Up @@ -930,14 +930,14 @@ def was_deleted(
# ==========================================================================

def _set_usn(self):
""" Update usn (update sequence number) for all changed rows. """
"""Update usn (update sequence number) for all changed rows."""
self.loc[
self.was_modified(na=True, _force=True),
_columns.columns_anki2ours[self._anki_table]["usn"],
] = -1

def _set_mod(self):
""" Update modification timestamps for all changed rows. """
"""Update modification timestamps for all changed rows."""
if self._anki_table in ["cards", "notes"]:
self.loc[
self.was_modified(na=True, _force=True),
Expand All @@ -946,7 +946,7 @@ def _set_mod(self):

# todo: test
def _set_guid(self):
""" Update globally unique id """
"""Update globally unique id"""
if self._anki_table == "notes":
self.loc[~self["nguid"].apply(bool)].apply(generate_guid)

Expand Down
10 changes: 5 additions & 5 deletions ankipandas/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ def __init__(self, path=None, user=None):

@property
def path(self) -> Path:
""" Path to currently loaded database """
"""Path to currently loaded database"""
return self._path

@property
def db(self) -> sqlite3.Connection:
""" Opened Anki database """
"""Opened Anki database"""
return self._db

def __del__(self):
Expand All @@ -99,7 +99,7 @@ def _get_item(self, item):

@property
def notes(self) -> AnkiDataFrame:
""" Notes as :class:`ankipandas.ankidf.AnkiDataFrame`. """
"""Notes as :class:`ankipandas.ankidf.AnkiDataFrame`."""
return self._get_item("notes")

@notes.setter
Expand All @@ -108,7 +108,7 @@ def notes(self, value):

@property
def cards(self) -> AnkiDataFrame:
""" Cards as :class:`ankipandas.ankidf.AnkiDataFrame`. """
"""Cards as :class:`ankipandas.ankidf.AnkiDataFrame`."""
return self._get_item("cards")

@cards.setter
Expand All @@ -117,7 +117,7 @@ def cards(self, value):

@property
def revs(self) -> AnkiDataFrame:
""" Reviews as :class:`ankipandas.ankidf.AnkiDataFrame`. """
"""Reviews as :class:`ankipandas.ankidf.AnkiDataFrame`."""
return self._get_item("revs")

@revs.setter
Expand Down
2 changes: 1 addition & 1 deletion ankipandas/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def db_path_input(path: Union[str, PurePath] = None, user: str = None) -> Path:


def db_backup_file_name() -> str:
""" Time based file name of the backup file. """
"""Time based file name of the backup file."""
return "backup-ankipandas-{}.anki2".format(
datetime.datetime.now().strftime("%Y-%m-%d-%H.%M.%S.%f")
)
Expand Down
2 changes: 1 addition & 1 deletion ankipandas/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def get_model2mid(db: sqlite3.Connection) -> Dict[str, int]:

@lru_cache(CACHE_SIZE)
def get_mid2sortfield(db: sqlite3.Connection) -> Dict[int, int]:
""" Mapping of model ID to index of sort field. """
"""Mapping of model ID to index of sort field."""
if get_db_version(db) == 0:
minfo = get_model_info(db)
_mid2sortfield = {mid: minfo[mid]["sortf"] for mid in minfo}
Expand Down
2 changes: 1 addition & 1 deletion ankipandas/util/checksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _strip_html(s):


def _strip_html_media(s):
""" Strip HTML but keep media filenames """
"""Strip HTML but keep media filenames"""
s = _reMedia.sub(" \\1 ", s)
return _strip_html(s)

Expand Down
2 changes: 1 addition & 1 deletion ankipandas/util/guid.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ def _guid64():


def guid():
""" Return globally unique ID """
"""Return globally unique ID"""
return _guid64()
4 changes: 2 additions & 2 deletions ankipandas/util/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def get_logger():
""" Sets up global logger. """
"""Sets up global logger."""
_log = colorlog.getLogger("AnkiPandas")

if _log.handlers:
Expand Down Expand Up @@ -59,7 +59,7 @@ def set_log_level(level: Union[str, int]) -> None:


def set_debug_log_level() -> None:
""" Set global log level to debug. """
"""Set global log level to debug."""
set_log_level(logging.DEBUG)


Expand Down
2 changes: 1 addition & 1 deletion ankipandas/util/test/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class TestLogging(unittest.TestCase):
""" Only tests that things run without error. """
"""Only tests that things run without error."""

def test_log(self):
log.info("Test info")
Expand Down
8 changes: 4 additions & 4 deletions ankipandas/util/types.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
def is_list_like(obj):
""" True if object type is similar to list, tuple etc. """
"""True if object type is similar to list, tuple etc."""
return isinstance(obj, (tuple, list))


def is_list_list_like(obj):
""" True if object is like-like object of list-like objects """
"""True if object is like-like object of list-like objects"""
return is_list_like(obj) and all(map(is_list_like, obj))


def is_list_dict_like(obj):
""" True if object is list-like object of dictionaries. """
"""True if object is list-like object of dictionaries."""
return is_list_like(obj) and all(map(lambda x: isinstance(x, dict), obj))


def is_dict_list_like(obj):
""" True if object is dictionary with list-like objects as values. """
"""True if object is dictionary with list-like objects as values."""
return isinstance(obj, dict) and all(map(is_list_like, obj.values()))

0 comments on commit 5cc272e

Please sign in to comment.