Skip to content

Commit

Permalink
Fix some typings
Browse files Browse the repository at this point in the history
  • Loading branch information
silvncr committed May 30, 2024
1 parent 73349d6 commit bebbf1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
23 changes: 12 additions & 11 deletions qrs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
__license__ = 'MIT'
__module_name__ = 'qrs'
__python_version__ = '3.8'
__version__ = '1.3.0'
__version__ = '1.3.1'


# get full wordlist from file
Expand All @@ -28,14 +28,14 @@
'wordlist.txt',
),
) as f:
wordlist_full = sorted(
wordlist_full: list[str] = sorted(
f.read().splitlines(),
)
max_length_full = max(len(word) for word in wordlist_full)
max_length_full: int = max(len(word) for word in wordlist_full)


# command line arguments; (arg, sarg, type, default, multiple, help)
qrs_kwargs = [
qrs_kwargs: list[tuple] = [
('debug', 'd', bool, False, ..., 'Whether to display debug information'),
('doubles', 'b', bool, False, ..., 'Whether to show longer, tied words'),
('exclude', 'e', str, [], True, 'List of words to exclude'),
Expand Down Expand Up @@ -280,7 +280,8 @@ def __getitem__(
Returns:
-------
The value of the given setting.
The value of the given setting. Can be any type, as defined in
`qrs_kwargs`.
'''

# return setting, or raise error
Expand Down Expand Up @@ -315,7 +316,7 @@ def solve(
self: Self,
query: str,
/,
) -> tuple[dict[int, list[str]], bool]:
) -> tuple[dict[int, tuple[list[str], int]], bool]:
'''
Finds all possible words that can be formed from the given query
string using the set wordlist.
Expand All @@ -335,7 +336,7 @@ def solve(
query = build_query(query, repeat_letters=not self['repeats'])

# initialise output object
scores = {}
scores: dict[int, tuple[list[str], int]] = {}

# prepare debug output
if self['debug']:
Expand All @@ -348,7 +349,7 @@ def solve(
)[::-1]:
scores = {
**scores,
len_iter: [[], 0],
len_iter: ([], 0),
}

# iterate through wordlist
Expand Down Expand Up @@ -430,7 +431,7 @@ def solve(

# update score
if not self['noscores']:
scores[len_iter][1] = self.scores[
scores[len_iter] = scores[len_iter][0], self.scores[
scores[len_iter][0][0]
]

Expand Down Expand Up @@ -505,7 +506,7 @@ def solve_str(
scores, anagram_found = self.solve(query)

# prepare anagram message
anagram_found = '' \
anagram_msg = '' \
if anagram_found \
else ' \t warning: anagram not found\n\n'

Expand All @@ -514,7 +515,7 @@ def solve_str(
f'\n \t--- query: {query} ({len(query)} letters'
+ (' + repeats' if self['repeats'] else '') + ') ---\n\n' + (
(
anagram_found + '\n\n'.join(
anagram_msg + '\n\n'.join(
f'\t{key} letters'
+ (
''
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,5 @@
'Programming Language :: Python',
'Topic :: Games/Entertainment :: Board Games',
'Topic :: Games/Entertainment :: Puzzle Games',
'Typing :: Typed',
],
)

0 comments on commit bebbf1d

Please sign in to comment.