mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-02-11 17:27:03 +00:00
make this thing a config and clean up lint
This commit is contained in:
parent
04e8aa39d2
commit
31caff037e
@ -1,19 +1,23 @@
|
|||||||
|
"""This is used by bin/codemod/remove_all_unused_functions to remove a function from a file."""
|
||||||
from bowler import Query
|
from bowler import Query
|
||||||
from bowler.types import Leaf
|
|
||||||
|
|
||||||
# This came about because vulture (actually dead, from the list of Similar programs at https://pypi.org/project/vulture/)
|
# This came about because vulture (actually dead, from the list of Similar programs at https://pypi.org/project/vulture/)
|
||||||
# actually found unused stuff, and I wanted to remove it.
|
# actually found unused stuff, and I wanted to remove it.
|
||||||
# See also https://github.com/craigds/decrapify
|
# See also https://github.com/craigds/decrapify
|
||||||
|
|
||||||
|
|
||||||
def remove_function(filename: str, function_name: str) -> None:
|
def remove_function(filename: str, function_name: str) -> None:
|
||||||
|
"""Does the dirty work of actually removing the function from the file in place, or failing if it cannot."""
|
||||||
|
|
||||||
def remove_statement(node, capture, filename):
|
def remove_statement(node, capture, filename):
|
||||||
node.remove()
|
node.remove()
|
||||||
|
|
||||||
bowler_query = (Query(filename)
|
bowler_query = (
|
||||||
|
Query(filename)
|
||||||
.select_function(function_name)
|
.select_function(function_name)
|
||||||
.modify(remove_statement)
|
.modify(remove_statement)
|
||||||
.execute(write=True, silent=True, interactive=False))
|
.execute(write=True, silent=True, interactive=False)
|
||||||
|
)
|
||||||
|
|
||||||
if len(bowler_query.exceptions) > 0:
|
if len(bowler_query.exceptions) > 0:
|
||||||
print(f"Failed to remove function {function_name} from {filename}.")
|
print(f"Failed to remove function {function_name} from {filename}.")
|
||||||
|
@ -11,6 +11,8 @@ from spiffworkflow_backend.services.process_instance_processor import (
|
|||||||
from spiffworkflow_backend.services.process_instance_service import (
|
from spiffworkflow_backend.services.process_instance_service import (
|
||||||
ProcessInstanceService,
|
ProcessInstanceService,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main."""
|
"""Main."""
|
||||||
app = get_hacked_up_app_for_script()
|
app = get_hacked_up_app_for_script()
|
||||||
|
@ -153,3 +153,9 @@ SPIFFWORKFLOW_BACKEND_FEATURE_ELEMENT_UNITS_ENABLED = (
|
|||||||
SPIFFWORKFLOW_BACKEND_ELEMENT_UNITS_CACHE_DIR = environ.get(
|
SPIFFWORKFLOW_BACKEND_ELEMENT_UNITS_CACHE_DIR = environ.get(
|
||||||
"SPIFFWORKFLOW_BACKEND_ELEMENT_UNITS_CACHE_DIR", default=None
|
"SPIFFWORKFLOW_BACKEND_ELEMENT_UNITS_CACHE_DIR", default=None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# adds the ProxyFix to Flask on http by processing the 'X-Forwarded-Proto' header
|
||||||
|
# to make SpiffWorkflow aware that it should return https for the server urls etc rather than http.
|
||||||
|
SPIFFWORKFLOW_BACKEND_USE_WERKZEUG_MIDDLEWARE_PROXY_FIX = (
|
||||||
|
environ.get("SPIFFWORKFLOW_BACKEND_USE_WERKZEUG_MIDDLEWARE_PROXY_FIX", default="false") == "true"
|
||||||
|
)
|
||||||
|
@ -7,8 +7,10 @@ from spiffworkflow_backend.services.acceptance_test_fixtures import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
app = create_app()
|
app = create_app()
|
||||||
if os.environ.get("SPIFFWORKFLOW_BACKEND_USE_WERKZEUG_MIDDLEWARE_PROXY_FIX") == "true":
|
|
||||||
|
if app.config["SPIFFWORKFLOW_BACKEND_USE_WERKZEUG_MIDDLEWARE_PROXY_FIX"]:
|
||||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
|
|
||||||
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1)
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1)
|
||||||
|
|
||||||
# this is in here because when we put it in the create_app function,
|
# this is in here because when we put it in the create_app function,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user