Skip to content

Commit dd43496

Browse files
committed
Fix showstopper bugs; misc tweaks
* Fix showstopper superhelp.this() bug * Push settings named tuple changes throughout code * Improve comment on constants * Bump version
1 parent 790283b commit dd43496

File tree

8 files changed

+19
-20
lines changed

8 files changed

+19
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Example HTML output](https://github.com/grantps/superhelp/raw/master/superhelp_logo_padded_small.png)
44

5-
version number: 1.0.12
5+
version number: 1.1.0
66
author: Grant Paton-Simpson
77

88
## Overview

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from codecs import open
33
from os import path
44

5-
__version__ = '1.0.12'
5+
__version__ = '1.1.0'
66

77
here = path.abspath(path.dirname(__file__))
88

superhelp/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .helper import this

superhelp/conf.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
## When testing user-supplied snippets watch out for the BOM MS inserts via Notepad. AST chokes on it.
2727
## All snippets here should be raw strings (see https://stackoverflow.com/questions/53636723/python-parsing-code-with-new-line-character-in-them-using-ast)
2828
TEST_SNIPPET = r"""
29-
for i in range(2):
30-
if var == 123:
31-
print(var)
32-
if var == 678:
33-
print(var)
29+
class Product:
30+
31+
def set_id(self, id):
32+
self.id = id
3433
"""
3534

3635
PY3_6 = '3.6'

superhelp/displayers/cli_displayer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import logging
21
from textwrap import dedent
32

43
from .cli_extras import md2cli
@@ -12,6 +11,8 @@
1211
1312
Lots in common with md displayer but risks of DRYing probably outweigh benefits
1413
at this stage.
14+
15+
Probably should swap out for https://github.com/willmcgugan/rich
1516
"""
1617

1718
from .. import conf

superhelp/gen_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,14 +537,14 @@ def _get_tidy_paragraph(raw_paragraph):
537537
lines are split to MAX_STD_LINE_LEN.
538538
539539
Remove lead and trailing new-lines - at the end there will always be two
540-
new-line characters added to the start.
540+
new-line characters added to the start.
541541
542542
:rtype: str
543543
"""
544544
## strip external new-line characters
545545
paragraph = raw_paragraph.strip()
546546
## remove supplied internal line-splitting
547-
one_line_paragraph = paragraph.replace('\n', ' ') ##
547+
one_line_paragraph = paragraph.replace('\n', ' ')
548548
needs_resplitting = _needs_resplitting_into_lines(one_line_paragraph)
549549
if needs_resplitting:
550550
wrapped_paragraph_lines = wrap(

superhelp/helper.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ def get_code_help(code, *, file_path=None,
110110
deferred_display = None
111111
return deferred_display
112112

113-
def get_script_help(file_path, *,
114-
output=conf.HTML, detail_level=conf.EXTRA, theme_name=None,
115-
warnings_only=False, execute_code=True, run_context=None):
113+
def get_script_help(file_path, *, output_settings=None,run_context=None):
116114
with open(file_path) as f:
117115
code = f.read()
118116
code = code.strip('\n')
@@ -124,9 +122,7 @@ def get_script_help(file_path, *,
124122
.replace('\nthis(', '\n# this(')
125123
)
126124
get_code_help(code, file_path=file_path,
127-
output=output, theme_name=theme_name, detail_level=detail_level,
128-
warnings_only=warnings_only, execute_code=execute_code,
129-
run_context=run_context)
125+
output_settings=output_settings, run_context=run_context)
130126

131127
def _get_file_paths(project_path, exclude_folders):
132128
"""

superhelp/helpers/magic_num_help.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def magic_number(block_dets, *, repeat=False, **_kwargs):
4545
+
4646
layout("""\
4747
or the snippet using "constant" SECONDS_IN_DAY, which has an obvious
48-
meaning:
48+
meaning:
4949
""")
5050
+
5151
layout("""\
@@ -57,9 +57,11 @@ def magic_number(block_dets, *, repeat=False, **_kwargs):
5757
Named constants are much more semantic i.e. readable. They clearly
5858
express their meaning.
5959
60-
Note - Python doesn't really have constants as such but it is
61-
conventional to use SCREAMING_SNAKE_CASE (capitals joined by
62-
underscores) to indicate a variable should be treated as a constant.
60+
A constant is a value which is fixed throughout the program e.g.
61+
SCREEN_WIDTH, PI, or GRAVITY. Note - Python doesn't really have
62+
constants as such but it is conventional to use SCREAMING_SNAKE_CASE
63+
(capitals joined by underscores) to indicate a variable should be
64+
treated as a constant.
6365
6466
Magic numbers make it hard to understand the code. They certainly
6567
make it more difficult to maintain and develop in the future when

0 commit comments

Comments
 (0)