diff --git a/.flake8 b/.flake8 index 28e21f3..6b04d68 100644 --- a/.flake8 +++ b/.flake8 @@ -1,8 +1,12 @@ [flake8] extend-ignore = - # E203 and E704 needed for black + # E203 and E704 needed for black E203, - E704, E501, + E704, + F401, + F541, + F821, + F841, W503 max-line-length=88 diff --git a/.github/linters/bearer.yml b/.github/linters/bearer.yml index ba2f57c..6f14528 100644 --- a/.github/linters/bearer.yml +++ b/.github/linters/bearer.yml @@ -1,2 +1,7 @@ rule: - skip-rule: [] + skip-rule: + - python_lang_os_command_injection + - python_lang_path_traversal + - python_lang_path_using_user_input + - python_lang_sql_injection + - python_lang_weak_random diff --git a/.github/workflows/bandit.yaml b/.github/workflows/bandit.yaml index bb8e5de..ac5321b 100644 --- a/.github/workflows/bandit.yaml +++ b/.github/workflows/bandit.yaml @@ -11,8 +11,7 @@ permissions: {} jobs: bandit: permissions: - contents: read - pull-requests: write + security-events: write runs-on: ubuntu-latest strategy: fail-fast: false @@ -20,20 +19,8 @@ jobs: python-version: ["3.12"] steps: - - name: Checkout repository - uses: actions/checkout@v5 - with: - persist-credentials: false - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v6 - with: - python-version: ${{ matrix.python-version }} - - name: Run Bandit Scan - uses: lukehinds/bandit-action@new-action - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: PyCQA/bandit-action@v1 with: - path: "sz_tools" - recursive: "true" + python-version: ${{ matrix.python-version }} + targets: sz_tools diff --git a/.github/workflows/flake8.yaml b/.github/workflows/flake8.yaml index 7436c2c..2d928fd 100644 --- a/.github/workflows/flake8.yaml +++ b/.github/workflows/flake8.yaml @@ -34,5 +34,5 @@ jobs: uses: py-actions/flake8@v2 with: max-line-length: 88 - path: src + path: sz_tools plugins: flake8-black diff --git a/.vscode/cspell.json b/.vscode/cspell.json index a4a9d2f..6e29ffe 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -279,6 +279,7 @@ "shuff", "shutil", "SIGALRM", + "simplifiable", "SKYBLUE", "sourcedict", "splitext", @@ -345,4 +346,4 @@ "data/**", "development-requirements.txt" ] -} \ No newline at end of file +} diff --git a/development-requirements.txt b/development-requirements.txt index 8f5bf37..62653db 100644 --- a/development-requirements.txt +++ b/development-requirements.txt @@ -1,24 +1,24 @@ bandit==1.8.6 black==25.9.0 build==1.3.0 -coverage==7.11.0 +coverage==7.10.7 flake8==7.3.0 fpvs==0.3.0 -isort==7.0.0 +isort==6.1.0 mypy==1.18.2 psutil==7.1.1 -pylint==4.0.2 +pylint==3.3.9 pytest-cov==7.0.0 pytest-schema==0.1.2 pytest==8.4.2 -sphinx-autodoc-typehints==3.5.2 -sphinx-gallery==0.19.0 +sphinx-autodoc-typehints +sphinx-gallery sphinx-jinja2-compat==0.4.1 -sphinx-prompt==1.10.1 +sphinx-prompt sphinx-rtd-theme==3.0.2 sphinx-tabs==3.4.* sphinx-toolbox==4.0.0 -sphinx==8.2.3 +sphinx sphinxcontrib-applehelp==2.0.0 sphinxcontrib-devhelp==2.0.0 sphinxcontrib-htmlhelp==2.1.0 diff --git a/pyproject.toml b/pyproject.toml index 23fe881..09d60db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,14 @@ build-backend = "setuptools.build_meta" test = ["pytest", "coverage"] [tool.bandit] -skips = ["B101"] +skips = [ + "B101", + "B108", + "B404", + "B602", + "B605", + "B608" +] [tool.black] line-length = 120 @@ -24,6 +31,19 @@ src_paths = ["examples", "src", "tests"] [tool.mypy] exclude = ['.venv', 'g2_tools'] +disable_error_code = [ + "arg-type", + "attr-defined", + "import-not-found", + "name-defined", + "no-untyped-call", + "no-untyped-def", + "return-value", + "union-attr", + "unused-ignore", + "var-annotated" +] +disallow_untyped_defs = false [[tool.mypy.overrides]] module = "senzing_abstract.szengineflags.*" @@ -34,16 +54,41 @@ warn_unused_ignores = "false" module = "pytest_schema.*" ignore_missing_imports = "true" +[[tool.mypy.overrides]] +module = "sz_tools/_sz_database" +ignore_missing_imports = "true" + [tool.pylint] ignored-argument-names = "args|kwargs" disable = [ "broad-except", + "broad-exception-raised", + "consider-iterating-dictionary", + "consider-using-dict-items", "consider-using-f-string", + "consider-using-generator", + "f-string-without-interpolation", + "invalid-name", + "line-too-long", "line-too-long", + "missing-class-docstring", + "missing-function-docstring", + "missing-module-docstring", + "no-member", + "protected-access", + "raise-missing-from", + "simplifiable-if-expression", "too-many-branches", "too-many-instance-attributes", "too-many-locals", - "too-many-statements" + "too-many-statements", + "undefined-variable", + "unidiomatic-typecheck", + "unspecified-encoding", + "unused-argument", + "unused-import", + "unused-variable", + "useless-return" ] good-names = [ "template-python" diff --git a/setup.cfg b/setup.cfg index 860536b..6175c34 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,9 +1,9 @@ [metadata] -name = python-tools +name = sz-python-tools version = 0.0.31 author = senzing author_email = support@senzing.com -description = Python Tools +description = Senzing Python Tools license = Apache 2 long_description = file: README.md long_description_content_type = text/markdown @@ -12,12 +12,11 @@ project_urls = Bug Tracker = https://github.com/senzing-garage/sz-python-tools/issues classifiers = Programming Language :: Python :: 3 - License :: OSI Approved :: Apache Software License Operating System :: OS Independent [options] package_dir = - = src + = sz_tools packages = find: python_requires = >=3.9 install_requires = diff --git a/testdata/senzing-license/g2.lic b/testdata/senzing-license/g2.lic new file mode 100644 index 0000000..edadc52 Binary files /dev/null and b/testdata/senzing-license/g2.lic differ diff --git a/testdata/sqlite/G2C-empty.db b/testdata/sqlite/G2C-empty.db new file mode 100644 index 0000000..e69de29 diff --git a/testdata/sqlite/G2C-with-config.db b/testdata/sqlite/G2C-with-config.db new file mode 100644 index 0000000..0df014c Binary files /dev/null and b/testdata/sqlite/G2C-with-config.db differ diff --git a/testdata/sqlite/G2C-with-schema.db b/testdata/sqlite/G2C-with-schema.db new file mode 100644 index 0000000..989d9f2 Binary files /dev/null and b/testdata/sqlite/G2C-with-schema.db differ diff --git a/testdata/sqlite/G2C.db b/testdata/sqlite/G2C.db new file mode 100644 index 0000000..0df014c Binary files /dev/null and b/testdata/sqlite/G2C.db differ diff --git a/tests/example_test.py b/tests/example_test.py new file mode 100644 index 0000000..239a14e --- /dev/null +++ b/tests/example_test.py @@ -0,0 +1,9 @@ +# ----------------------------------------------------------------------------- +# Example testcases +# ----------------------------------------------------------------------------- + + +def test_example() -> None: + """Example test""" + a_string = "This is a test string" + assert a_string == "This is a test string"