Skip to content

Commit c43b1ec

Browse files
authored
Merge branch 'main' into dependabot/github_actions/dot-github/workflows/actions/download-artifact-4.1.7
2 parents 2676ec9 + 61f8a5e commit c43b1ec

File tree

9 files changed

+48
-54
lines changed

9 files changed

+48
-54
lines changed

.github/workflows/build_and_publish.yml

+15-9
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,24 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
os: [ ubuntu-20.04, windows-2019, macos-11 ]
15+
# macos-13 is pre-ARM
16+
os: [ ubuntu-24.04, windows-2019, macos-13, macos-latest ]
1617

1718
steps:
1819
- uses: actions/checkout@v4
1920
with:
2021
fetch-depth: 0
2122

2223
- name: Build wheels
23-
uses: pypa/cibuildwheel@v2.19.1
24+
uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3
25+
env:
26+
CIBW_SKIP: pp*
2427

25-
- uses: actions/upload-artifact@v3
28+
- uses: actions/upload-artifact@v4
2629
with:
30+
name: pytsql-wheel-${{ matrix.os }}
2731
path: ./wheelhouse/*.whl
32+
if-no-files-found: error
2833

2934
build_sdist:
3035
name: Build source distribution
@@ -37,22 +42,23 @@ jobs:
3742
- name: Build sdist
3843
run: pipx run build --sdist
3944

40-
- uses: actions/upload-artifact@v3
45+
- uses: actions/upload-artifact@v4
4146
with:
47+
name: pytsql-sdist
4248
path: dist/*.tar.gz
49+
if-no-files-found: error
4350

4451
upload_pypi:
4552
name: Upload to PyPI
4653
needs: [build_wheels, build_sdist]
54+
environment: pypi
4755
runs-on: ubuntu-latest
4856
if: github.event_name == 'release' && github.event.action == 'published'
4957
steps:
5058
- uses: actions/download-artifact@v4.1.7
5159
with:
52-
name: artifact
60+
pattern: pytsql-*
61+
merge-multiple: true
5362
path: dist
5463

55-
- uses: pypa/gh-action-pypi-publish@v1.10.0
56-
with:
57-
user: __token__
58-
password: ${{ secrets.PYPI_TOKEN }}
64+
- uses: pypa/gh-action-pypi-publish@v1.10.2

.github/workflows/ci.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
fail-fast: true
2929
matrix:
30-
PYTHON_VERSION: ['3.8', '3.9', '3.10', '3.11']
30+
PYTHON_VERSION: ['3.9', '3.10', '3.11']
3131
OS: ['ubuntu-latest', 'windows-latest']
3232
steps:
3333
- name: Checkout branch
@@ -56,7 +56,7 @@ jobs:
5656
strategy:
5757
fail-fast: false
5858
matrix:
59-
PYTHON_VERSION: ['3.8', '3.9', '3.10', '3.11']
59+
PYTHON_VERSION: ['3.9', '3.10', '3.11']
6060
services:
6161
DB:
6262
image: mcr.microsoft.com/mssql/server:2019-latest

.github/workflows/update_grammar.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Install package
3636
run: pip install .
3737
- name: Create Pull Request
38-
uses: peter-evans/create-pull-request@v6
38+
uses: peter-evans/create-pull-request@v7
3939
with:
4040
delete-branch: true
4141
title: "Autoupdate grammar targets based on antlr/grammars-v4's TSQL grammar definition"

environment.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ channels:
33
- conda-forge
44
- nodefaults
55
dependencies:
6-
- python>=3.8
6+
- python>=3.9
77
- setuptools_scm
88
- pre-commit
99
- pytest
@@ -20,3 +20,4 @@ dependencies:
2020
- antlr4-python3-runtime==4.13.1 # keep `.github/workflows/update_grammar.yml` in sync
2121
- click
2222
- openjdk
23+
- compilers

pyproject.toml

+9-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
requires = ['setuptools', 'setuptools-scm', 'wheel']
33
build-backend = "setuptools.build_meta"
44

5+
[tool.setuptools_scm]
6+
version_scheme = "post-release"
7+
8+
59
[project]
610
name = "pytsql"
711
description = "`Pytsql` allows to run mssql sripts, typically run via GUIs, via CLI."
@@ -25,7 +29,6 @@ classifiers = [
2529
"License :: OSI Approved :: BSD License",
2630
"Operating System :: OS Independent",
2731
"Programming Language :: Python :: 3",
28-
"Programming Language :: Python :: 3.8",
2932
"Programming Language :: Python :: 3.9",
3033
"Programming Language :: Python :: 3.10",
3134
"Programming Language :: Python :: 3.11",
@@ -34,7 +37,7 @@ classifiers = [
3437
readme = "README.md"
3538
dynamic = ["version"]
3639

37-
requires-python = ">=3.8.0"
40+
requires-python = ">=3.9"
3841

3942
dependencies = [
4043
"sqlalchemy >=1.4",
@@ -70,8 +73,10 @@ module = "pytsql.grammar.*"
7073
follow_imports = "silent"
7174

7275
[tool.ruff]
73-
ignore = ["E501", "N803", "N806"]
7476
line-length = 88
77+
78+
[tool.ruff.lint]
79+
ignore = ["E501", "N803", "N806"]
7580
select = [
7681
# pyflakes
7782
"F",
@@ -84,8 +89,7 @@ select = [
8489
# pyupgrade
8590
"UP",
8691
]
87-
target-version = "py38"
8892
exclude=["src/pytsql/grammar/**/*.py"]
8993

90-
[tool.ruff.isort]
94+
[tool.ruff.lint.isort]
9195
known-first-party = ["pytsql"]

setup.py

-19
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
11
import glob
22
import platform
3-
from time import time
43

54
import setuptools
6-
from setuptools_scm.version import ScmVersion
7-
8-
9-
def get_dev_timestamp(version: ScmVersion) -> str:
10-
"""Return a new distribution version string.
11-
12-
Returns the version found in the git tag if currently checked out commit has a tag.
13-
Otherwise, returns the version found in the most recent git tag, appended with
14-
`dev` and the current timestamp in seconds.
15-
"""
16-
17-
if version.exact:
18-
return version.format_with("{tag}")
19-
return version.format_with(f"{{tag}}.dev{int(time())}")
205

216

227
def get_platform() -> str:
@@ -61,10 +46,6 @@ def create_extension() -> setuptools.Extension:
6146
def run_setup():
6247
setuptools.setup(
6348
ext_modules=[create_extension()],
64-
use_scm_version={
65-
"version_scheme": get_dev_timestamp,
66-
"local_scheme": "dirty-tag",
67-
},
6849
)
6950

7051

src/pytsql/__init__.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
"""`Pytsql` allows to run mssql sripts, typically run via GUIs, via CLI."""
22

3-
import pkg_resources
3+
import importlib.metadata
4+
import warnings
45

56
from .tsql import execute, executes
67

78
try:
8-
__version__ = pkg_resources.get_distribution(__name__).version
9-
except Exception:
9+
__version__ = importlib.metadata.version(__name__)
10+
except importlib.metadata.PackageNotFoundError as e: # pragma: no cover
11+
warnings.warn(f"Could not determine version of {__name__}\n{e!s}", stacklevel=2)
1012
__version__ = "unknown"
1113

14+
1215
__all__ = ["execute", "executes"]

src/pytsql/tsql.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import warnings
44
from pathlib import Path
55
from re import Match
6-
from typing import Any, Dict, List, Optional, Union
6+
from typing import Any, Optional, Union
77

88
import antlr4.tree.Tree
99
import sqlalchemy
@@ -28,7 +28,7 @@ def _code(path: Union[str, Path], encoding: str) -> str:
2828
return "\n".join(fh.readlines())
2929

3030

31-
def _process_replacement(line: str, parameters: Dict[str, Any]) -> str:
31+
def _process_replacement(line: str, parameters: dict[str, Any]) -> str:
3232
"""Appropriately replace a single <replace> statement."""
3333
new_line = line.format(**parameters)
3434
if None in parameters.values():
@@ -42,7 +42,7 @@ def _process_replacement(line: str, parameters: Dict[str, Any]) -> str:
4242

4343
def _parametrize(
4444
source: str,
45-
parameters: Dict[str, Any],
45+
parameters: dict[str, Any],
4646
start: str = _REPLACE_START,
4747
end: str = _REPLACE_END,
4848
) -> str:
@@ -93,7 +93,7 @@ def __init__(self):
9393
# session information is lost after the execution of a batch.
9494
# We therefore need to manually prepend it to all following
9595
# batches.
96-
self.dynamics: List[str] = []
96+
self.dynamics: list[str] = []
9797

9898
def visit(
9999
self, tree: TSqlParser.Sql_clausesContext, prepend_dynamics: bool = True
@@ -112,7 +112,7 @@ def visit(
112112

113113
return " ".join(dynamics + chunks)
114114

115-
def visitChildren(self, node: antlr4.ParserRuleContext) -> List[str]: # noqa: N802
115+
def visitChildren(self, node: antlr4.ParserRuleContext) -> list[str]: # noqa: N802
116116
if isinstance(node, TSqlParser.Print_statementContext):
117117
# Print statements are replaced by inserts into a temporary table so that they can be evaluated
118118
# at the right time and fetched afterwards.
@@ -129,15 +129,15 @@ def visitChildren(self, node: antlr4.ParserRuleContext) -> List[str]: # noqa: N
129129

130130
return result
131131

132-
def visitTerminal(self, node: antlr4.TerminalNode) -> List[str]: # noqa: N802
132+
def visitTerminal(self, node: antlr4.TerminalNode) -> list[str]: # noqa: N802
133133
return [str(node)]
134134

135-
def defaultResult(self) -> List[str]: # noqa: N802
135+
def defaultResult(self) -> list[str]: # noqa: N802
136136
return []
137137

138138
def aggregateResult( # noqa: N802
139-
self, aggregate: List[str], next_result: List[str]
140-
) -> List[str]:
139+
self, aggregate: list[str], next_result: list[str]
140+
) -> list[str]:
141141
return aggregate + next_result
142142

143143

@@ -158,7 +158,7 @@ def syntaxError( # noqa: N802
158158
raise ValueError(f"Error parsing SQL script: {error_message}")
159159

160160

161-
def _split(code: str, isolate_top_level_statements: bool = True) -> List[str]:
161+
def _split(code: str, isolate_top_level_statements: bool = True) -> list[str]:
162162
if not USE_CPP_IMPLEMENTATION:
163163
warnings.warn(
164164
"Can not find C++ version of the parser, Python version will be used instead."
@@ -215,7 +215,7 @@ def _fetch_and_clear_prints(conn: Connection):
215215
def executes(
216216
code: str,
217217
engine: sqlalchemy.engine.Engine,
218-
parameters: Optional[Dict[str, Any]] = None,
218+
parameters: Optional[dict[str, Any]] = None,
219219
isolate_top_level_statements=True,
220220
) -> None:
221221
"""Execute a given sql string through a sqlalchemy.engine.Engine connection.
@@ -250,7 +250,7 @@ def executes(
250250
def execute(
251251
path: Union[str, Path],
252252
engine: sqlalchemy.engine.Engine,
253-
parameters: Optional[Dict[str, Any]] = None,
253+
parameters: Optional[dict[str, Any]] = None,
254254
isolate_top_level_statements=True,
255255
encoding: str = "utf-8",
256256
) -> None:

tests/unit/test_py_vs_cpp.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import inspect
22
import re
3-
from typing import List
43
from unittest import mock
54

65
import pytest
@@ -36,7 +35,7 @@ def seed():
3635
GROUP BY nr, short_nr;"""
3736

3837

39-
def get_rule_labels(context_cls: ParserRuleContext) -> List[str]:
38+
def get_rule_labels(context_cls: ParserRuleContext) -> list[str]:
4039
init_func = context_cls.__init__
4140

4241
# Detect any context/token labels from the init function's assignments

0 commit comments

Comments
 (0)