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

Lint Action using black #134

Merged
merged 3 commits into from Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Expand Up @@ -63,5 +63,5 @@ jobs:
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
src: "./mediawiki/*"
# src: "./mediawiki/*"
version: "22.8.0"
4 changes: 2 additions & 2 deletions tests/__init__.py
@@ -1,3 +1,3 @@
'''
"""
Testing Module
'''
"""
28 changes: 15 additions & 13 deletions tests/utilities.py
@@ -1,40 +1,42 @@
''' random functions that will be needed for the tests '''
""" random functions that will be needed for the tests """


class FunctionUseCounter(object):
''' decorator to keep a running count of how many
times function has been called; stop at 50 '''
"""decorator to keep a running count of how many
times function has been called; stop at 50"""

def __init__(self, func):
''' init decorator '''
"""init decorator"""
self.func = func
self.count = 0

def __call__(self, *args, **kwargs):
''' what to do when called '''
"""what to do when called"""
self.count += 1
if self.count > 50: # arbitrary large
return dict()
return self.func(*args, **kwargs)


def find_depth(node):
''' find depth of tree '''
"""find depth of tree"""

def walk(next_node, depth):
''' walk down tree finding depth '''
"""walk down tree finding depth"""
if next_node is None:
return depth
if 'sub-categories' not in next_node:
if "sub-categories" not in next_node:
return depth
if next_node['sub-categories'] is None:
if next_node["sub-categories"] is None:
return depth

if len(next_node['sub-categories'].keys()) == 0:
return next_node['depth']
if len(next_node["sub-categories"].keys()) == 0:
return next_node["depth"]
else:
for key in next_node['sub-categories'].keys():
path_depth = walk(next_node['sub-categories'][key], depth)
for key in next_node["sub-categories"].keys():
path_depth = walk(next_node["sub-categories"][key], depth)
if path_depth and path_depth > depth:
depth = path_depth
return depth

return walk(node, 0)