Skip to content

Commit c145b95

Browse files
committed
style: lint and format warnings fixed
1 parent 35d0ee9 commit c145b95

26 files changed

+141
-265
lines changed

doc/server.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ Server running in new thread created by PyRFC is started using ``start()`` metho
3636

3737
.. literalinclude:: ../examples/server/server_pyrfc_thread.py
3838
:language: python
39-
:lines: 41-54
39+
:lines: 42-61
4040

4141
and can be stopped using ``close()`` method:
4242

4343
.. literalinclude:: ../examples/server/server_pyrfc_thread.py
4444
:language: python
45-
:lines: 61-62
45+
:lines: 63-64
4646

4747
Example: `server_pyrfc_thread.py <https://github.com/SAP/PyRFC/blob/master/examples/server/server_pyrfc_thread.py>`_
4848

@@ -63,13 +63,13 @@ new thread started by application:
6363

6464
.. literalinclude:: ../examples/server/server_app_thread.py
6565
:language: python
66-
:lines: 33-60
66+
:lines: 34-64
6767

6868
and stopped by application:
6969

7070
.. literalinclude:: ../examples/server/server_app_thread.py
7171
:language: python
72-
:lines: 62-63
72+
:lines: 66-67
7373

7474
Example: `server_app_thread.py <https://github.com/SAP/PyRFC/blob/master/examples/server/server_app_thread.py>`_
7575

examples/clientIDoc.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def initial_screen():
1818
# print("\t2: Display current pending IDocs")
1919
print("\t0:\t Exit")
2020
try:
21-
choice = int(input("Enter choice: ")) # WPS110
21+
choice = int(input("Enter choice: "))
2222
except ValueError:
2323
choice = 0
2424
return choice
@@ -74,17 +74,15 @@ def main():
7474
unit = connection.initialize_unit(background=False)
7575
print(f" - (t/qRFC) Using unit id = {unit['id']}")
7676
if choice == 2: # bgRFC, type 'Q'
77-
queue_input = input(
78-
"Enter queue names (comma separated): "
79-
) # WPS110
77+
queue_input = input("Enter queue names (comma separated): ")
8078
queue_names = [qi.strip() for qi in queue_input.split(",")]
8179
connection.fill_and_submit_unit(
8280
unit,
8381
[("IDOC_INBOUND_ASYNCHRONOUS", idoc)],
8482
queue_names=queue_names,
8583
)
8684
elif choice == 4: # qRFC
87-
queue_input = input("Enter queue name: ") # WPS110
85+
queue_input = input("Enter queue name: ")
8886
queue = queue_input.strip()
8987
connection.fill_and_submit_unit(
9088
unit,

examples/clientPrintDescription.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def main(function_name): # noqa: PLR0912
7373
field_widths = [20, 17, 10, 10, 9, 9, 10, 15]
7474

7575
sys.stdout.write(
76-
" -----------( Structure of {0.name} (n/uc_length={0.nuc_length}/{0.uc_length})--\n".format(
76+
" -----------( Structure of {0.name} (n/uc_length={0.nuc_length}/{0.uc_length})--\n".format( # noqa: E501
7777
type_desc
7878
)
7979
)

examples/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get_error(
2626
error = {}
2727
ex_type_full = str(type(ex))
2828
print(ex_type_full)
29-
# error["type"] = ex_type_full[ex_type_full.rfind(".") + 1 : ex_type_full.rfind("'")]
29+
# error["type"] = ex_type_full[ex_type_full.rfind(".") + 1 : ex_type_full.rfind("'")] # noqa: E501
3030
error["code"] = ex.code if "code" in ex else "<None>"
3131
error["key"] = ex.key if "key" in ex else "<None>"
3232
error["message"] = ex.message.split("\n")

examples/server/bgrfc_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
print(unit, client.get_unit_state(unit))
2424

25-
input("Press Enter ...\n") # WPS110
25+
input("Press Enter ...\n")
2626

2727
print(unit, client.get_unit_state(unit))
2828

examples/server/bgrfc_server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def onGetStateFunction(rfcHandle, unit_identifier):
179179
# start server
180180
server.start()
181181

182-
input("Press Enter key to stop server...\n") # WPS110
182+
input("Press Enter key to stop server...\n")
183183

184184
# stop server and database
185185
server.stop()

examples/server/server_app_thread.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99

1010
def my_stfc_connection(request_context=None, REQUTEXT=""):
11-
"""Server function my_stfc_connection with the signature of ABAP function module STFC_CONNECTION."""
11+
"""Server function my_stfc_connection with the signature
12+
of ABAP function module STFC_CONNECTION."""
1213

1314
print("stfc connection invoked")
1415
print("request_context", request_context)
@@ -35,17 +36,20 @@ def launch_server():
3536

3637
# create server for ABAP system ABC
3738
server = Server(
38-
{"dest": "gateway"},
39-
{"dest": "MME"},
40-
{"check_date": False, "check_time": False, "port": 8081, "server_log": False},
39+
server_params={"dest": "gateway"},
40+
client_params={"dest": "MME"},
41+
config={
42+
"check_date": False,
43+
"check_time": False,
44+
"port": 8081,
45+
"server_log": False,
46+
},
4147
)
4248
print(server.get_server_attributes())
4349

44-
# expose python function my_stfc_connection as ABAP function STFC_CONNECTION, to be called by ABAP system
45-
server.add_function(
46-
"STFC_CONNECTION",
47-
my_stfc_connection,
48-
)
50+
# expose python function my_stfc_connection as ABAP function STFC_CONNECTION,
51+
# to be called by ABAP system
52+
server.add_function("STFC_CONNECTION", my_stfc_connection)
4953

5054
# start server
5155
server.serve()
@@ -57,7 +61,7 @@ def launch_server():
5761
server_thread = Thread(target=launch_server)
5862
server_thread.start()
5963

60-
input("Press Enter to stop server...") # WPS110
64+
input("Press Enter to stop server...")
6165

6266
# stop server
6367
server_thread.join()

examples/server/server_errors.py

+7-13
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import sys
66

77
from backends import BACKEND
8-
9-
from pyrfc import ExternalRuntimeError, Server
8+
from pyrfc import Server
109

1110
backend_dest = sys.argv[1]
1211

@@ -29,29 +28,24 @@ def my_stfc_connection(request_context=None, REQUTEXT=""):
2928
print("request_context", request_context)
3029
print(f"REQUTEXT: {REQUTEXT}")
3130

32-
raise ExternalRuntimeError(**errorInfo)
31+
# raise ExternalRuntimeError(**errorInfo)
3332
# raise ABAPRuntimeError(**errorInfo)
3433
# raise ABAPApplicationError(**errorInfo)
3534

36-
return {
37-
"ECHOTEXT": REQUTEXT,
38-
"RESPTEXT": "Python server here",
39-
}
35+
return {"ECHOTEXT": REQUTEXT, "RESPTEXT": "Python server here"}
4036

4137

4238
# create server
4339
server = Server(*BACKEND[backend_dest])
4440

45-
# expose python function my_stfc_connection as ABAP function STFC_CONNECTION, to be called by ABAP system
46-
server.add_function(
47-
"STFC_CONNECTION",
48-
my_stfc_connection,
49-
)
41+
# expose python function my_stfc_connection as ABAP function STFC_CONNECTION,
42+
# to be called by ABAP system
43+
server.add_function("STFC_CONNECTION", my_stfc_connection)
5044

5145
# start server
5246
server.start()
5347

54-
input("Press Enter to stop server...") # WPS110
48+
input("Press Enter to stop server...")
5549

5650
# stop server
5751
server.stop()

examples/server/server_pyrfc_thread.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77

88
def my_stfc_structure(request_context=None, IMPORTSTRUCT=None, RFCTABLE=None):
9-
"""Server function my_stfc_structure with the signature of ABAP function module STFC_STRUCTURE."""
9+
"""Server function my_stfc_structure with the signature
10+
of ABAP function module STFC_STRUCTURE."""
1011

1112
print("stfc structure invoked")
1213
print("request_context", request_context)
@@ -40,14 +41,15 @@ def my_auth_check(func_name=False, request_context=None):
4041

4142
# create server
4243
server = Server(
43-
{"dest": "MME_GATEWAY"},
44-
{"dest": "MME"},
45-
{"check_date": False, "check_time": False, "server_log": True},
44+
server_params={"dest": "MME_GATEWAY"},
45+
client_params={"dest": "MME"},
46+
config={"check_date": False, "check_time": False, "server_log": True},
4647
)
4748

4849
print(server.options)
4950

50-
# expose python function my_stfc_structure as ABAP function STFC_STRUCTURE, to be called by ABAP system
51+
# expose python function my_stfc_structure as ABAP function STFC_STRUCTURE
52+
# to be called from ABAP system
5153
server.add_function("STFC_STRUCTURE", my_stfc_structure)
5254

5355
# start server
@@ -56,7 +58,7 @@ def my_auth_check(func_name=False, request_context=None):
5658
# get server attributes
5759
print(server.get_server_attributes())
5860

59-
input("Press Enter to stop server...") # WPS110
61+
input("Press Enter to stop server...")
6062

6163
# shutdown server
6264
server.close()

examples/serverStfcConnection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def my_stfc_connection(
1616
"request_context",
1717
request_context,
1818
)
19-
print("REQUTEXT: {REQUTEXT}")
19+
print(f"REQUTEXT: {REQUTEXT}")
2020
return {
2121
"ECHOTEXT": REQUTEXT,
2222
"RESPTEXT": "Python server here",

pyproject.toml

+1-8
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,14 @@ select = [
8080
]
8181

8282
[tool.ruff.lint.mccabe]
83-
max-complexity = 10
83+
max-complexity = 12
8484

8585
[tool.ruff.lint.per-file-ignores]
8686
"src/pyrfc/__init__.py" = ["F401"]
87-
"tests/test_server.py" = ["E402"]
8887

8988
[tool.ruff.format]
9089
# same as Black
9190
quote-style = "double"
92-
93-
# same as Black
9491
indent-style = "space"
95-
96-
# same as Black
9792
skip-magic-trailing-comma = false
98-
99-
# same as Black
10093
line-ending = "auto"

setup.py

+8-14
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,15 @@
2222
from Cython.Build import cythonize
2323
from Cython.Distutils import build_ext
2424
except ImportError:
25-
sys.exit(
26-
"Cython not installed: https://cython.readthedocs.io/en/latest/src/quickstart/install.html"
27-
)
25+
sys.exit("Cython not installed")
2826
CMDCLASS = {"build_ext": build_ext}
2927

3028
# check if SAP NWRFC SDK configured
3129
SAPNWRFC_HOME = os.environ.get("SAPNWRFC_HOME")
3230
if not SAPNWRFC_HOME:
3331
sys.exit(
3432
"Environment variable SAPNWRFC_HOME not set.\n"
35-
"Please specify this variable with the root directory of the SAP NWRFC Library."
33+
"This variable shall point to the root directory of the SAP NWRFC Library."
3634
)
3735

3836

@@ -70,13 +68,11 @@
7068
# https://docs.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-alphabetically
7169

7270
# Python sources
73-
PYTHONSOURCE = os.environ.get("PYTHONSOURCE")
71+
PYTHONSOURCE = os.getenv(
72+
"PYTHONSOURCE", inspect.getfile(inspect).split("/inspect.py")[0]
73+
)
7474
if not PYTHONSOURCE:
75-
PYTHONSOURCE = inspect.getfile(inspect).split("/inspect.py")[0]
76-
# sys.exit(
77-
# "Environment variable PYTHONSOURCE not set."
78-
# "Please specify this variable with the root directory of PYTHONSOURCE Library."
79-
# )
75+
sys.exit("Environment variable PYTHONSOURCE not set.")
8076

8177
LIBS = ["sapnwrfc", "libsapucum"]
8278

@@ -194,9 +190,7 @@
194190

195191
setup(
196192
name=PACKAGE_NAME,
197-
cmdclass=CMDCLASS, # type: ignore
198-
ext_modules=cythonize(PYRFC_EXT, annotate=True) # type: ignore
199-
if build_cython
200-
else [PYRFC_EXT], # type: ignore
193+
cmdclass=CMDCLASS,
194+
ext_modules=cythonize(PYRFC_EXT, annotate=True) if build_cython else [PYRFC_EXT],
201195
test_suite="tests",
202196
)

0 commit comments

Comments
 (0)