Skip to content

Commit cf521c9

Browse files
authored
Merge pull request #75 from mikez/main
Update docstrings: remove redundant ones and tweak spelling on others.
2 parents 3cc98f3 + 619739d commit cf521c9

File tree

3 files changed

+24
-50
lines changed

3 files changed

+24
-50
lines changed

docs/things/database.html

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,12 @@ <h1 class="modulename">
581581
<span class="c1"># -------- Utility methods --------</span>
582582

583583
<span class="k">def</span> <span class="nf">last_modified</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
584-
<span class="sd">&quot;&quot;&quot;Get last modified time.&quot;&quot;&quot;</span>
584+
<span class="sd">&quot;&quot;&quot;Get last modified time of database filepath.&quot;&quot;&quot;</span>
585585
<span class="n">mtime_seconds</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">getmtime</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filepath</span><span class="p">)</span>
586586
<span class="k">return</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">fromtimestamp</span><span class="p">(</span><span class="n">mtime_seconds</span><span class="p">)</span>
587587

588588
<span class="k">def</span> <span class="nf">was_modified_today</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
589-
<span class="sd">&quot;&quot;&quot;Return true of modification date is `&gt;=` that todays date.&quot;&quot;&quot;</span>
589+
<span class="sd">&quot;&quot;&quot;Return True if database filepath was last modified today.&quot;&quot;&quot;</span>
590590
<span class="n">last_modified_date</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">last_modified</span><span class="p">()</span><span class="o">.</span><span class="n">date</span><span class="p">()</span>
591591
<span class="n">todays_date</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span><span class="o">.</span><span class="n">date</span><span class="p">()</span>
592592
<span class="k">return</span> <span class="n">last_modified_date</span> <span class="o">&gt;=</span> <span class="n">todays_date</span>
@@ -756,7 +756,7 @@ <h1 class="modulename">
756756

757757
<span class="k">def</span> <span class="nf">make_date_filter</span><span class="p">(</span><span class="n">date_column</span><span class="p">,</span> <span class="n">offset</span><span class="p">):</span>
758758
<span class="sd">&quot;&quot;&quot;</span>
759-
<span class="sd"> Return an SQL filter to limit the date range of the SQL query.</span>
759+
<span class="sd"> Return a SQL filter to limit the date range of the SQL query.</span>
760760

761761
<span class="sd"> Parameters</span>
762762
<span class="sd"> ----------</span>
@@ -806,7 +806,7 @@ <h1 class="modulename">
806806

807807
<span class="k">def</span> <span class="nf">make_truthy_filter</span><span class="p">(</span><span class="n">column</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
808808
<span class="sd">&quot;&quot;&quot;</span>
809-
<span class="sd"> Return an SQL filter adding a boolean column that is set to truthy or falsy.</span>
809+
<span class="sd"> Return a SQL filter that matches if a column is truthy or falsy.</span>
810810

811811
<span class="sd"> Truthy means TRUE. Falsy means FALSE or NULL. This is akin</span>
812812
<span class="sd"> to how Python defines it natively.</span>
@@ -835,7 +835,7 @@ <h1 class="modulename">
835835

836836
<span class="k">def</span> <span class="nf">make_search_filter</span><span class="p">(</span><span class="n">query</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
837837
<span class="sd">&quot;&quot;&quot;</span>
838-
<span class="sd"> Return an SQL filter that filters titles and notes by a string.</span>
838+
<span class="sd"> Return a SQL filter to search tasks by a string query.</span>
839839

840840
<span class="sd"> Example:</span>
841841
<span class="sd"> --------</span>
@@ -1267,12 +1267,12 @@ <h1 class="modulename">
12671267
<span class="c1"># -------- Utility methods --------</span>
12681268

12691269
<span class="k">def</span> <span class="nf">last_modified</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
1270-
<span class="sd">&quot;&quot;&quot;Get last modified time.&quot;&quot;&quot;</span>
1270+
<span class="sd">&quot;&quot;&quot;Get last modified time of database filepath.&quot;&quot;&quot;</span>
12711271
<span class="n">mtime_seconds</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">getmtime</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filepath</span><span class="p">)</span>
12721272
<span class="k">return</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">fromtimestamp</span><span class="p">(</span><span class="n">mtime_seconds</span><span class="p">)</span>
12731273

12741274
<span class="k">def</span> <span class="nf">was_modified_today</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
1275-
<span class="sd">&quot;&quot;&quot;Return true of modification date is `&gt;=` that todays date.&quot;&quot;&quot;</span>
1275+
<span class="sd">&quot;&quot;&quot;Return True if database filepath was last modified today.&quot;&quot;&quot;</span>
12761276
<span class="n">last_modified_date</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">last_modified</span><span class="p">()</span><span class="o">.</span><span class="n">date</span><span class="p">()</span>
12771277
<span class="n">todays_date</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span><span class="o">.</span><span class="n">date</span><span class="p">()</span>
12781278
<span class="k">return</span> <span class="n">last_modified_date</span> <span class="o">&gt;=</span> <span class="n">todays_date</span>
@@ -1829,14 +1829,14 @@ <h6 id="parameters">Parameters</h6>
18291829
<details>
18301830
<summary>View Source</summary>
18311831
<div class="codehilite"><pre><span></span> <span class="k">def</span> <span class="nf">last_modified</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
1832-
<span class="sd">&quot;&quot;&quot;Get last modified time.&quot;&quot;&quot;</span>
1832+
<span class="sd">&quot;&quot;&quot;Get last modified time of database filepath.&quot;&quot;&quot;</span>
18331833
<span class="n">mtime_seconds</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">getmtime</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filepath</span><span class="p">)</span>
18341834
<span class="k">return</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">fromtimestamp</span><span class="p">(</span><span class="n">mtime_seconds</span><span class="p">)</span>
18351835
</pre></div>
18361836

18371837
</details>
18381838

1839-
<div class="docstring"><p>Get last modified time.</p>
1839+
<div class="docstring"><p>Get last modified time of database filepath.</p>
18401840
</div>
18411841

18421842

@@ -1852,15 +1852,15 @@ <h6 id="parameters">Parameters</h6>
18521852
<details>
18531853
<summary>View Source</summary>
18541854
<div class="codehilite"><pre><span></span> <span class="k">def</span> <span class="nf">was_modified_today</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
1855-
<span class="sd">&quot;&quot;&quot;Return true of modification date is `&gt;=` that todays date.&quot;&quot;&quot;</span>
1855+
<span class="sd">&quot;&quot;&quot;Return True if database filepath was last modified today.&quot;&quot;&quot;</span>
18561856
<span class="n">last_modified_date</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">last_modified</span><span class="p">()</span><span class="o">.</span><span class="n">date</span><span class="p">()</span>
18571857
<span class="n">todays_date</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span><span class="o">.</span><span class="n">date</span><span class="p">()</span>
18581858
<span class="k">return</span> <span class="n">last_modified_date</span> <span class="o">&gt;=</span> <span class="n">todays_date</span>
18591859
</pre></div>
18601860

18611861
</details>
18621862

1863-
<div class="docstring"><p>Return true of modification date is <code>&gt;=</code> that todays date.</p>
1863+
<div class="docstring"><p>Return True if database filepath was last modified today.</p>
18641864
</div>
18651865

18661866

@@ -2162,7 +2162,7 @@ <h6 id="examples">Examples</h6>
21622162
<summary>View Source</summary>
21632163
<div class="codehilite"><pre><span></span><span class="k">def</span> <span class="nf">make_date_filter</span><span class="p">(</span><span class="n">date_column</span><span class="p">,</span> <span class="n">offset</span><span class="p">):</span>
21642164
<span class="sd">&quot;&quot;&quot;</span>
2165-
<span class="sd"> Return an SQL filter to limit the date range of the SQL query.</span>
2165+
<span class="sd"> Return a SQL filter to limit the date range of the SQL query.</span>
21662166

21672167
<span class="sd"> Parameters</span>
21682168
<span class="sd"> ----------</span>
@@ -2212,7 +2212,7 @@ <h6 id="examples">Examples</h6>
22122212

22132213
</details>
22142214

2215-
<div class="docstring"><p>Return an SQL filter to limit the date range of the SQL query.</p>
2215+
<div class="docstring"><p>Return a SQL filter to limit the date range of the SQL query.</p>
22162216

22172217
<h6 id="parameters">Parameters</h6>
22182218

@@ -2257,7 +2257,7 @@ <h6 id="examples">Examples</h6>
22572257
<summary>View Source</summary>
22582258
<div class="codehilite"><pre><span></span><span class="k">def</span> <span class="nf">make_truthy_filter</span><span class="p">(</span><span class="n">column</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
22592259
<span class="sd">&quot;&quot;&quot;</span>
2260-
<span class="sd"> Return an SQL filter adding a boolean column that is set to truthy or falsy.</span>
2260+
<span class="sd"> Return a SQL filter that matches if a column is truthy or falsy.</span>
22612261

22622262
<span class="sd"> Truthy means TRUE. Falsy means FALSE or NULL. This is akin</span>
22632263
<span class="sd"> to how Python defines it natively.</span>
@@ -2286,7 +2286,7 @@ <h6 id="examples">Examples</h6>
22862286

22872287
</details>
22882288

2289-
<div class="docstring"><p>Return an SQL filter adding a boolean column that is set to truthy or falsy.</p>
2289+
<div class="docstring"><p>Return a SQL filter that matches if a column is truthy or falsy.</p>
22902290

22912291
<p>Truthy means TRUE. Falsy means FALSE or NULL. This is akin
22922292
to how Python defines it natively.</p>
@@ -2322,7 +2322,7 @@ <h6 id="examples">Examples</h6>
23222322
<summary>View Source</summary>
23232323
<div class="codehilite"><pre><span></span><span class="k">def</span> <span class="nf">make_search_filter</span><span class="p">(</span><span class="n">query</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
23242324
<span class="sd">&quot;&quot;&quot;</span>
2325-
<span class="sd"> Return an SQL filter that filters titles and notes by a string.</span>
2325+
<span class="sd"> Return a SQL filter to search tasks by a string query.</span>
23262326

23272327
<span class="sd"> Example:</span>
23282328
<span class="sd"> --------</span>
@@ -2348,7 +2348,7 @@ <h6 id="examples">Examples</h6>
23482348

23492349
</details>
23502350

2351-
<div class="docstring"><p>Return an SQL filter that filters titles and notes by a string.</p>
2351+
<div class="docstring"><p>Return a SQL filter to search tasks by a string query.</p>
23522352

23532353
<h2 id="example">Example:</h2>
23542354

tests/test_things.py

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ class ThingsCase(unittest.TestCase): # noqa: V103 pylint: disable=R0904
2020
"""Class documentation goes here."""
2121

2222
def setUp(self):
23-
"""Set up environment variables."""
2423
# Set environment variable to test database
2524
self.saved_filepath = os.getenv(THINGSDB)
2625
os.environ[THINGSDB] = TEST_DATABASE_FILEPATH
2726

2827
def tearDown(self):
29-
"""Restore environment variables."""
3028
# Restore environment variable to its previous value
3129
# or delete it if it wasn't set before running the test.
3230
if self.saved_filepath is None:
@@ -36,20 +34,17 @@ def tearDown(self):
3634
os.environ[THINGSDB] = self.saved_filepath
3735

3836
def test_get_tag_by_database_filepath(self):
39-
"""Test get tag by database filepath."""
4037
del os.environ[THINGSDB]
4138
tag_uuid = "Qt2AY87x2QDdowSn9HKTt1"
4239
tag = things.get(tag_uuid, filepath=TEST_DATABASE_FILEPATH)
4340
self.assertEqual(tag["uuid"], tag_uuid) # type: ignore
4441

4542
def test_get_url_scheme_auth_token(self):
46-
"""Test get url scheme auth token."""
4743
expected = "vKkylosuSuGwxrz7qcklOw"
4844
token = things.token()
4945
self.assertEqual(token, expected)
5046

5147
def test_search(self):
52-
"""Test search."""
5348
tasks = things.search("wrong_query")
5449
self.assertEqual(0, len(tasks))
5550

@@ -71,12 +66,10 @@ def test_search(self):
7166
self.assertEqual(3, len(todos))
7267

7368
def test_inbox(self):
74-
"""Test inbox."""
7569
tasks = things.inbox()
7670
self.assertEqual(2, len(tasks))
7771

7872
def test_trashed(self):
79-
"""Test getting trashed tasks."""
8073
tasks = things.trash()
8174
self.assertEqual(5, len(tasks))
8275
todos = things.todos(trashed=True)
@@ -102,55 +95,45 @@ def test_trashed(self):
10295
self.assertEqual(0, len(tasks))
10396

10497
def test_upcoming(self):
105-
"""Test upcoming."""
10698
tasks = things.upcoming()
10799
self.assertEqual(1, len(tasks))
108100

109101
def test_deadlines(self):
110-
"""Test deadlines."""
111102
tasks = things.deadlines()
112103
self.assertEqual(1, len(tasks))
113104

114105
def test_today(self):
115-
"""Test today."""
116106
tasks = things.today()
117107
self.assertEqual(3, len(tasks))
118108

119109
def test_checklist(self):
120-
"""Test checklist."""
121110
checklist_items = things.checklist_items("3Eva4XFof6zWb9iSfYy4ej")
122111
self.assertEqual(3, len(checklist_items))
123112
checklist_items = things.checklist_items("K9bx7h1xCJdevvyWardZDq")
124113
self.assertEqual(0, len(checklist_items))
125114

126115
def test_anytime(self):
127-
"""Test anytime."""
128116
tasks = things.anytime()
129117
self.assertEqual(12, len(tasks))
130118
self.assertTrue(any(task.get("area_title") == "Area 1" for task in tasks))
131119

132120
def test_logbook(self):
133-
"""Test logbook."""
134121
tasks = things.logbook()
135122
self.assertEqual(21, len(tasks))
136123

137124
def test_canceled(self):
138-
"""Test canceled."""
139125
tasks = things.canceled()
140126
self.assertEqual(11, len(tasks))
141127

142128
def test_completed(self):
143-
"""Test completed."""
144129
tasks = things.completed()
145130
self.assertEqual(10, len(tasks))
146131

147132
def test_someday(self):
148-
"""Test someday."""
149133
tasks = things.someday()
150134
self.assertEqual(1, len(tasks))
151135

152-
def test_get(self):
153-
"""Test the function to find an object by `uuid`."""
136+
def test_get_by_uuid(self):
154137
task = things.get("wrong_uuid")
155138
self.assertEqual(None, task)
156139
task = things.get("wrong_uuid", "NOT FOUND")
@@ -159,7 +142,6 @@ def test_get(self):
159142
self.assertEqual(4, len(task.keys())) # type: ignore
160143

161144
def test_todos(self):
162-
"""Test all to-dos."""
163145
todos = things.todos(start="Anytime")
164146
self.assertEqual(8, len(todos))
165147
todos = things.todos(start="Anytime", status="completed")
@@ -176,7 +158,6 @@ def test_todos(self):
176158
self.assertEqual(16, len(todo.keys())) # type: ignore
177159

178160
def test_tags(self):
179-
"""Test all tags."""
180161
tags = things.tags()
181162
self.assertEqual(5, len(tags))
182163
tags = things.tags(include_items=True)
@@ -187,19 +168,16 @@ def test_tags(self):
187168
self.assertEqual("Errand", tag["title"]) # type: ignore
188169

189170
def test_get_link(self):
190-
"""Test get link."""
191171
link = things.link("uuid")
192172
self.assertEqual("things:///show?id=uuid", link)
193173

194174
def test_projects(self):
195-
"""Test all projects."""
196175
projects = things.projects()
197176
self.assertEqual(3, len(projects))
198177
projects = things.projects(include_items=True)
199178
self.assertEqual(2, len(projects[0]["items"]))
200179

201180
def test_areas(self):
202-
"""Test all test_areas."""
203181
areas = things.areas()
204182
self.assertEqual(3, len(areas))
205183
areas = things.areas(include_items=True)
@@ -212,12 +190,10 @@ def test_areas(self):
212190
self.assertEqual("Area 3", area["title"]) # type: ignore
213191

214192
def test_database_version(self):
215-
"""Test database version."""
216193
version = things.Database().get_version()
217194
self.assertEqual(18, version)
218195

219196
def test_last(self):
220-
"""Test last parameter."""
221197
last_tasks = things.last("0d")
222198
self.assertEqual(len(last_tasks), 0)
223199

@@ -243,7 +219,6 @@ def test_last(self):
243219
things.last("3X")
244220

245221
def test_tasks(self):
246-
"""Test tasks."""
247222
count = things.tasks(status="completed", last="100y", count_only=True)
248223
self.assertEqual(count, 10)
249224
# special characters
@@ -256,8 +231,7 @@ def test_tasks(self):
256231
with self.assertRaises(ValueError):
257232
things.tasks(area="\0")
258233

259-
def test_database(self):
260-
"""Test some database details."""
234+
def test_database_details(self):
261235
output = io.StringIO()
262236
with contextlib.redirect_stdout(output):
263237
things.areas(print_sql=True)

things/database.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,12 +451,12 @@ def execute_query(self, sql_query, parameters=(), row_factory=None):
451451
# -------- Utility methods --------
452452

453453
def last_modified(self):
454-
"""Get last modified time."""
454+
"""Get last modified time of database filepath."""
455455
mtime_seconds = os.path.getmtime(self.filepath)
456456
return datetime.datetime.fromtimestamp(mtime_seconds)
457457

458458
def was_modified_today(self):
459-
"""Return true of modification date is `>=` that todays date."""
459+
"""Return True if database filepath was last modified today."""
460460
last_modified_date = self.last_modified().date()
461461
todays_date = datetime.datetime.now().date()
462462
return last_modified_date >= todays_date
@@ -626,7 +626,7 @@ def make_filter(column, value):
626626

627627
def make_date_filter(date_column, offset):
628628
"""
629-
Return an SQL filter to limit the date range of the SQL query.
629+
Return a SQL filter to limit the date range of the SQL query.
630630
631631
Parameters
632632
----------
@@ -676,7 +676,7 @@ def make_date_filter(date_column, offset):
676676

677677
def make_truthy_filter(column: str, value) -> str:
678678
"""
679-
Return an SQL filter adding a boolean column that is set to truthy or falsy.
679+
Return a SQL filter that matches if a column is truthy or falsy.
680680
681681
Truthy means TRUE. Falsy means FALSE or NULL. This is akin
682682
to how Python defines it natively.
@@ -705,7 +705,7 @@ def make_truthy_filter(column: str, value) -> str:
705705

706706
def make_search_filter(query: str) -> str:
707707
"""
708-
Return an SQL filter that filters titles and notes by a string.
708+
Return a SQL filter to search tasks by a string query.
709709
710710
Example:
711711
--------

0 commit comments

Comments
 (0)