diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0e4988b..127a43f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,7 @@ Fixes #__. -Changes in PR: +To do: + - [ ] ... + +Cuurent changes in PR: - ... diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..a116b10 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,43 @@ +name: Formatting + +on: push + +jobs: + formatting-isort: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.11.1 + + - name: Code Formatting (App) + run: | + pip install -r requirements-dev.txt + isort --check . + + formatting-ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.11.1 + + - name: Code Formatting (App) + run: | + pip install -r requirements-dev.txt + ruff format --check . + + ruff-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.11.1 + + - name: Code Formatting (App) + run: | + pip install -r requirements-dev.txt + ruff check . diff --git a/.github/workflows/isort.yml b/.github/workflows/isort.yml deleted file mode 100644 index 3257dc9..0000000 --- a/.github/workflows/isort.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Isort Formatting - -on: push - -jobs: - formatting-isort: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.11.1 - - - name: Code Formatting (App) - run: | - pip install -r requirements-dev.txt - isort --check . diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 17e9931..f4a7a92 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -1,4 +1,4 @@ -name: Upload salve to Pypi +name: Upload token_tools to Pypi on: release: diff --git a/.github/workflows/ruff-format.yml b/.github/workflows/ruff-format.yml deleted file mode 100644 index 16adc33..0000000 --- a/.github/workflows/ruff-format.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Ruff Formatting - -on: push - -jobs: - formatting-ruff: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.11.1 - - - name: Code Formatting (App) - run: | - pip install -r requirements-dev.txt - ruff format --check . diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml deleted file mode 100644 index 98f68b8..0000000 --- a/.github/workflows/ruff.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Ruff Check - -on: push - -jobs: - ruff-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.11.1 - - - name: Code Formatting (App) - run: | - pip install -r requirements-dev.txt - ruff check . diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index afc9074..427337c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,7 +3,7 @@ name: Code Tests on: push jobs: - testing: + testing-ubuntu: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -16,3 +16,31 @@ jobs: pip install . pip install -r requirements-dev.txt python3 -m pytest . + + testing-macos: + runs-on: macos-13 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.11.1 + + - name: Run tests + run: | + pip install . + pip install -r requirements-dev.txt + python3 -m pytest . + + testing-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.11.1 + + - name: Run tests + run: | + pip install . + pip install -r requirements-dev.txt + python3 -m pytest . -s diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml deleted file mode 100644 index 25e1368..0000000 --- a/.github/workflows/windows-tests.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Code Tests (On Windows) - -on: push - -jobs: - testing-windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.11.1 - - - name: Run tests - run: | - pip install . - pip install -r requirements-dev.txt - python3 -m pytest . -s diff --git a/token_tools/token.py b/token_tools/token.py index 78b76fd..4f22e40 100644 --- a/token_tools/token.py +++ b/token_tools/token.py @@ -5,16 +5,14 @@ Token = tuple[tuple[int, int], int, str] GENERIC_TOKENS: list[str] = [ - "Whitespace", - "Text", + "Identifier", # Variable "Error", "Keyword", - "Name", + "Type", "String", "Number", "Literal", "Operator", "Punctuation", "Comment", - "Generic", ] diff --git a/token_tools/token_funcs.py b/token_tools/token_funcs.py index f02ca23..2e72f2e 100644 --- a/token_tools/token_funcs.py +++ b/token_tools/token_funcs.py @@ -8,10 +8,10 @@ def normal_text_range( """Takes the full text and a text range (inclusively numbered) and returns the split text and a tuple with the proper text range.""" # Text range is the first and last line inclusively with -1 for the end line indicating that it goes until the last line split_text: list[str] = full_text.splitlines() + split_len: int = len(split_text) - if text_range[1] == -1: - # This indicates that the text range should span the length of the entire code - split_len: int = len(split_text) + if text_range[1] > split_len or text_range[1] == -1: + # This indicates that the text range should span the length of the entire code or is too long split_len = ( 1 if split_len == 0 else split_len ) # If its a one line code snippet, we need to +1