Skip to content

Commit 8bea64d

Browse files
authored
Merge pull request #70 from eseglem/develop
Cleanup and Updates
2 parents 07b2d60 + 857804a commit 8bea64d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1833
-1171
lines changed

.editorconfig

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
[*]
2-
end_of_line = lf
3-
insert_final_newline = true
4-
5-
[*.py]
62
charset = utf-8
3+
insert_final_newline = true
4+
end_of_line = lf
75
indent_style = space
6+
trim_trailing_whitespace = true
87
indent_size = 4
98

10-
[*.json]
11-
indent_style = space
9+
[*.json,*.yaml,*.yml]
1210
indent_size = 2

.github/workflows/release.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
run-tests:
8+
uses: ./.github/workflows/tests.yaml
9+
10+
release:
11+
runs-on: ubuntu-latest
12+
environment: release
13+
permissions:
14+
contents: write
15+
id-token: write
16+
17+
steps:
18+
- name: Checkout the repository
19+
uses: actions/checkout@v4
20+
21+
- name: Install poetry
22+
run: pipx install poetry
23+
24+
- name: Set up Python 3.12
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.12"
28+
cache: poetry
29+
30+
- name: Install dependencies
31+
run: poetry install --no-dev
32+
33+
- name: Get release version
34+
id: release-version
35+
run: echo "RELEASE_VERSION=v$(poetry version --short)" >> "$GITHUB_OUTPUT"
36+
37+
- name: Build package
38+
run: poetry build
39+
40+
- name: Upload the files to the release
41+
uses: ncipollo/release-action@v1
42+
with:
43+
artifacts: ${{ github.workspace }}/dist/*
44+
tag: ${{ steps.release-version.outputs.RELEASE_VERSION }}
45+
commit: ${{ github.sha }}
46+
omitBody: true
47+
48+
- name: Publish package
49+
uses: pypa/gh-action-pypi-publish@release/v1
50+
with:
51+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/tests.yaml

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,42 @@ name: Tests
22

33
on:
44
push:
5-
branches: [main]
6-
tags: ["v*"]
5+
branches:
6+
- main
7+
- develop
78
pull_request:
8-
branches: [main]
9+
branches:
10+
- main
11+
- develop
12+
workflow_call:
913

1014
jobs:
1115
tests:
1216
runs-on: ubuntu-latest
1317
strategy:
1418
matrix:
15-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
19+
python-version:
20+
- "3.8"
21+
- "3.9"
22+
- "3.10"
23+
- "3.11"
24+
- "3.12"
1625

1726
steps:
18-
- uses: actions/checkout@v4
27+
- name: Checkout the repository
28+
uses: actions/checkout@v4
29+
1930
- name: Install poetry
2031
run: pipx install poetry
32+
2133
- name: Set up Python ${{ matrix.python-version }}
2234
uses: actions/setup-python@v5
2335
with:
2436
python-version: ${{ matrix.python-version }}
25-
cache: "poetry"
37+
cache: poetry
38+
2639
- name: Install dependencies
2740
run: poetry install -E test
28-
- name: Run tests with coverage
29-
run: poetry run pytest --ignore=tests/test_pycql2_hypothesis.py --cov=pycql2 --cov-report=xml tests/
3041

31-
publish:
32-
needs: [tests]
33-
runs-on: ubuntu-latest
34-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
35-
steps:
36-
- uses: actions/checkout@v4
37-
- name: Install poetry
38-
run: pipx install poetry
39-
- name: Set up Python 3.12
40-
uses: actions/setup-python@v5
41-
with:
42-
python-version: 3.12
43-
cache: "poetry"
44-
- name: Install dependencies
45-
run: poetry install --no-dev
46-
- name: Build package
47-
run: poetry build
48-
- name: Publish package
49-
uses: pypa/gh-action-pypi-publish@release/v1
50-
with:
51-
password: ${{ secrets.PYPI_API_TOKEN }}
42+
- name: Run tests with coverage
43+
run: poetry run pytest --ignore=tests/test_pycql2_hypothesis.py --cov=pycql2 --cov-report=term-missing tests/

.gitignore

Lines changed: 119 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/linux,macos,direnv,python,windows,visualstudiocode
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=linux,macos,direnv,python,windows,visualstudiocode
3+
4+
### direnv ###
5+
.direnv
6+
.envrc
7+
8+
### Linux ###
9+
*~
10+
11+
# temporary files which can be created if a process still has a handle open of a deleted file
12+
.fuse_hidden*
13+
14+
# KDE directory preferences
15+
.directory
16+
17+
# Linux trash folder which might appear on any partition or disk
18+
.Trash-*
19+
20+
# .nfs files are created when an open file is removed but is still being accessed
21+
.nfs*
22+
23+
### macOS ###
24+
# General
25+
.DS_Store
26+
.AppleDouble
27+
.LSOverride
28+
29+
# Icon must end with two \r
30+
Icon
31+
32+
33+
# Thumbnails
34+
._*
35+
36+
# Files that might appear in the root of a volume
37+
.DocumentRevisions-V100
38+
.fseventsd
39+
.Spotlight-V100
40+
.TemporaryItems
41+
.Trashes
42+
.VolumeIcon.icns
43+
.com.apple.timemachine.donotpresent
44+
45+
# Directories potentially created on remote AFP share
46+
.AppleDB
47+
.AppleDesktop
48+
Network Trash Folder
49+
Temporary Items
50+
.apdisk
51+
52+
### macOS Patch ###
53+
# iCloud generated files
54+
*.icloud
55+
56+
### Python ###
157
# Byte-compiled / optimized / DLL files
258
__pycache__/
359
*.py[cod]
@@ -152,5 +208,66 @@ dmypy.json
152208
# Cython debug symbols
153209
cython_debug/
154210

155-
# VSCode
156-
.vscode/
211+
# PyCharm
212+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
213+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
214+
# and can be added to the global gitignore or merged into this file. For a more nuclear
215+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
216+
#.idea/
217+
218+
### Python Patch ###
219+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
220+
poetry.toml
221+
222+
# ruff
223+
.ruff_cache/
224+
225+
# LSP config files
226+
pyrightconfig.json
227+
228+
### VisualStudioCode ###
229+
.vscode/*
230+
!.vscode/settings.json
231+
!.vscode/tasks.json
232+
!.vscode/launch.json
233+
!.vscode/extensions.json
234+
!.vscode/*.code-snippets
235+
236+
# Local History for Visual Studio Code
237+
.history/
238+
239+
# Built Visual Studio Code Extensions
240+
*.vsix
241+
242+
### VisualStudioCode Patch ###
243+
# Ignore all local history of files
244+
.history
245+
.ionide
246+
247+
### Windows ###
248+
# Windows thumbnail cache files
249+
Thumbs.db
250+
Thumbs.db:encryptable
251+
ehthumbs.db
252+
ehthumbs_vista.db
253+
254+
# Dump file
255+
*.stackdump
256+
257+
# Folder config file
258+
[Dd]esktop.ini
259+
260+
# Recycle Bin used on file shares
261+
$RECYCLE.BIN/
262+
263+
# Windows Installer files
264+
*.cab
265+
*.msi
266+
*.msix
267+
*.msm
268+
*.msp
269+
270+
# Windows shortcuts
271+
*.lnk
272+
273+
# End of https://www.toptal.com/developers/gitignore/api/linux,macos,direnv,python,windows,visualstudiocode

.pre-commit-config.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@ repos:
1818
- id: pyupgrade
1919
args: ["--py38-plus", "--keep-runtime-typing"]
2020
- repo: https://github.com/astral-sh/ruff-pre-commit
21-
rev: v0.1.11
21+
rev: v0.2.0
2222
hooks:
2323
- id: ruff
2424
args: ["--fix"]
25-
- repo: https://github.com/psf/black
26-
rev: 23.12.1
27-
hooks:
28-
- id: black
29-
language_version: python
25+
- id: ruff-format
3026
- repo: https://github.com/pre-commit/mirrors-mypy
3127
rev: v1.8.0
3228
hooks:

.vscode/extensions.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"recommendations": [
3+
"charliermarsh.ruff",
4+
"DavidAnson.vscode-markdownlint",
5+
"EditorConfig.EditorConfig",
6+
"esbenp.prettier-vscode",
7+
"ms-python.debugpy",
8+
"ms-python.python",
9+
"ms-python.vscode-pylance",
10+
"tamasfe.even-better-toml"
11+
]
12+
}

.vscode/settings.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"[json]": {
3+
"editor.defaultFormatter": "esbenp.prettier-vscode"
4+
},
5+
"[python]": {
6+
"editor.codeActionsOnSave": {
7+
"source.fixAll": "always",
8+
"source.organizeImports": "always"
9+
},
10+
"editor.defaultFormatter": "charliermarsh.ruff",
11+
"editor.formatOnSave": true,
12+
"editor.inlineSuggest.enabled": true
13+
},
14+
"python.testing.unittestEnabled": false,
15+
"python.testing.pytestEnabled": true,
16+
"markdownlint.config": {
17+
"ul-indent": {
18+
"indent": 4
19+
}
20+
}
21+
}

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,36 @@ When parsing cql2-text to cql2-json.
1414
- `... NOT IN ...` become `NOT ... IN ...`
1515
- `... IS NOT NULL` becomes `NOT ... IS NULL`
1616
- Negative arithmetic operands become a multiply by -1: `{"op": "*", "params": [-1, <arithmetic_operand>]}`
17+
- Within a Character Literal, the character (`'` or `\`) used to escape a single quote is not preserved.
18+
- Any `''` will become `\'`
1719

1820
The cql2-text output from the pydantic models is opinionated and explicit. These choices have been made to keep the logic simple while ensuring the correctness of the output.
1921

2022
- All property names are double quoted `"`.
23+
- Character Literals escape single quotes with a backslash `\'`.
2124
- Parenthesis `()` are placed around all comparison and arithmetic operations.
22-
- This means that many outputs include a set of parentheses around the whole string. While this is not ideal, it is also not incorrect. When more tests are in place, they can be used to determine if a safe and easy way exists to remove them.
25+
- This means that many outputs include a set of parentheses around the whole string.
26+
- This may not be not ideal, but it is also not incorrect.
27+
- Additional testing may be done in the future to determine if a safe and easy way exists to remove them.
2328
- Timestamps always contain decimal seconds out to 6 decimal places even when 0: `.000000`. It uses `strftime` with `%f` currently. Logic may be added later to adjust this.
2429
- Floats ending in `.0` will include the `.0` in the text. Where other libraries such as `shapely` will not include them in WKT.
2530

2631
The cql2-text spec was not strictly followed for WKT. Some tweaks were made to increase it is compatible with `geojson-pydantic`, as well as accept the WKT output.
2732

28-
- Added optional `Z` to each geometry. It doesn't enforce 2d / 3d, just allows the character to be there.
33+
- Added optional `Z` to each geometry.
34+
- This does not enforce 2d / 3d, just allows the character to be there.
2935
- LineString coordinates require a minimum of 2 coordinates.
30-
- Added 'Linear Ring' for use in Polygons with a minimum of 4 coordinates. It doesn't enforce the ring being closed, just that it has enough coordinates to be one.
36+
- Added 'Linear Ring' for use in Polygons with a minimum of 4 coordinates.
37+
- This does not enforce the ring being closed, just that it contains enough coordinates to be one.
3138
- Moved BBOX so it cannot be included in GeometryCollection.
32-
- Moved GeometryCollection to not allow nesting, until support is added to `geojson-pydantic`.
39+
- Added alternative MultiPoint syntax to maintain compatibility with other spatial tools and libraries.
40+
- Allows reading of `MUTLIPOINT(0 0, 1 1)` without the inner parenthesis.
41+
- This may be removed in the future if it is no longer necessary for compatibility. Removal will be considered a breaking change and be versioned as such.
42+
- Note: Output will always include the inner parenthesis (via `geojson-pydantic`).
3343

3444
There are a few things which **may** be issues with the spec but have not been fully addressed yet.
3545

36-
- (Partially addressed) `spatial_literal` includes `geometry_collection` and `bbox`, and `geometry_collection` allows for all `spatial_literal` within it. But `bbox` does not seem to be a part of WKT. And at least within GeoJSON, nested `GeometryCollection` "SHOULD be avoided". This would mean the `cql2-text -> cql2-json` conversion would break where `geojson-pydantic` doesn't accept these cases.
46+
- `spatial_literal` includes `bbox`, and `geometry_collection` allows for all `spatial_literal` within it. But `bbox` does not seem to be a part of WKT. This would mean the `cql2-text -> cql2-json` conversion would break where `geojson-pydantic` doesn't accept these cases.
3747
- The spec does not allow for `EMPTY` geometries.
3848

3949
## Testing
@@ -45,7 +55,6 @@ Each file in `tests/data/json/` is a standalone cql2-json example. There will be
4555
While 100% of the lines of code are covered, more complex examples with more nested logic will be added in the future. As well as more variety to various inputs, the current examples are mostly PropertyRef and numbers. Such as:
4656

4757
- More complex identifiers with `_`, `.`, `:`, and non ascii letters.
48-
- Character literals with escaped quote.
4958
- Deeply nested logic.
5059
- Each type of `scalar_expression` on each side of a `binary_comparison_predicate`, etc.
5160

0 commit comments

Comments
 (0)