Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/os.py" "${CMAKE_CURRENT_
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/platform.py" "${CMAKE_CURRENT_BINARY_DIR}/src/runtime/platform.py")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/random.py" "${CMAKE_CURRENT_BINARY_DIR}/src/runtime/random.py")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/statistics.py" "${CMAKE_CURRENT_BINARY_DIR}/src/runtime/statistics.py")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/string.py" "${CMAKE_CURRENT_BINARY_DIR}/src/runtime/string.py")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/sys.py" "${CMAKE_CURRENT_BINARY_DIR}/src/runtime/sys.py")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/time.py" "${CMAKE_CURRENT_BINARY_DIR}/src/runtime/time.py")

Expand Down
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ RUN(NAME test_str_03 LABELS cpython llvm llvm_jit c)
RUN(NAME test_str_04 LABELS cpython llvm llvm_jit c wasm)
RUN(NAME test_str_05 LABELS cpython llvm llvm_jit c)
RUN(NAME test_str_06 LABELS cpython llvm llvm_jit c)
RUN(NAME test_string_01 LABELS cpython llvm llvm_jit c)
RUN(NAME test_list_01 LABELS cpython llvm llvm_jit c)
RUN(NAME test_list_02 LABELS cpython llvm llvm_jit c)
RUN(NAME test_list_03 LABELS cpython llvm llvm_jit c NOFAST)
Expand Down
7 changes: 7 additions & 0 deletions integration_tests/test_string_01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from string import ascii_lowercase, ascii_letters

def test_string():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to call the function below ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in #2788

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps one can write a custom flake8 plugin using https://pypi.org/project/flake8-plugin-utils/ that checks all functions that are defined, are being called.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it has to be custom. You could probably use ruff, too :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LPython itself should give a warning for something like this.

assert ascii_lowercase == 'abcdefghijklmnopqrstuvwxyz'
assert ascii_letters == 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

print(ascii_lowercase)
9 changes: 9 additions & 0 deletions src/runtime/string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
whitespace : str = ' \t\n\r\v\f'
ascii_lowercase : str = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase : str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_letters : str = ascii_lowercase + ascii_uppercase
digits : str = '0123456789'
hexdigits : str = digits + 'abcdef' + 'ABCDEF'
octdigits : str = '01234567'
punctuation : str = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
printable : str = digits + ascii_letters + punctuation + whitespace