diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44600b8..5f8e055 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,6 @@ jobs: - dependencies: > bandit libatomic - monkeytype pylint python3-dbus python3-dbus-signature-pyparsing diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml deleted file mode 100644 index 6fe892c..0000000 --- a/.github/workflows/push.yml +++ /dev/null @@ -1,64 +0,0 @@ ---- -name: on push - -# yamllint disable-line rule:truthy -on: - push: - branches: [master] - - pull_request: - branches: [master] - - workflow_dispatch: - -jobs: - monkeytype: - runs-on: ubuntu-24.04 - container: - image: fedora:42 # CURRENT DEVELOPMENT ENVIRONMENT - steps: - - name: Install dependencies for Fedora - run: > - dnf install -y - bandit - black - git - make - monkeytype - pip - pylint - python3-dbus - python3-dbus-signature-pyparsing - python3-hypothesis - python3-isort - - name: Install hs-dbus-signature - run: pip install --user hs-dbus-signature - - uses: actions/checkout@v6 - with: - path: into-dbus-python - persist-credentials: false - - name: Run with monkeytype - run: > - MONKEYTYPE=1 - PYTHONPATH=./src:/github/home/.local/lib/python3.13/site-packages - make test - # tests may fail due to timeouts, call traces should be fine - continue-on-error: true - working-directory: into-dbus-python - - name: Apply annotations - run: PYTHONPATH=./src make apply - working-directory: into-dbus-python - - name: Format result - run: make fmt - working-directory: into-dbus-python - - name: Install pyright - run: pip install --user pyright - - name: Lint result - run: > - PATH=${PATH}:/github/home/.local/bin - PYTHONPATH=./src make -f Makefile lint - working-directory: into-dbus-python - continue-on-error: true - - name: Diff the result - run: git diff --exit-code - working-directory: into-dbus-python diff --git a/Makefile b/Makefile index 9845cbc..2f49f67 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,11 @@ -ifeq ($(origin MONKEYTYPE), undefined) - PYTHON = python3 -else - PYTHON = MONKEYTYPE_TRACE_MODULES=into_dbus_python monkeytype run -endif - -ISORT_MODULES = monkeytype_config.py setup.py src tests - -MONKEYTYPE_MODULES = into_dbus_python._signature +ISORT_MODULES = setup.py src tests .PHONY: lint lint: pylint setup.py - pylint monkeytype_config.py pylint src/into_dbus_python pylint tests bandit setup.py - bandit monkeytype_config.py # Ignore B101 errors. We do not distribute optimized code, i.e., .pyo # files in Fedora, so we do not need to have concerns that assertions # are removed by optimization. @@ -25,7 +15,7 @@ lint: .PHONY: test test: - ${PYTHON} -m unittest discover --verbose tests + python3 -m unittest discover --verbose tests .PHONY: coverage coverage: @@ -54,13 +44,3 @@ yamllint: .PHONY: package package: (umask 0022; python -m build; python -m twine check --strict ./dist/*) - -.PHONY: apply -apply: - @echo "Modules traced:" - @monkeytype list-modules - @echo - @echo "Annotating:" - @for module in ${MONKEYTYPE_MODULES}; do \ - monkeytype --verbose apply --sample-count --ignore-existing-annotations $${module} > /dev/null; \ - done diff --git a/monkeytype_config.py b/monkeytype_config.py deleted file mode 100644 index 6e148b7..0000000 --- a/monkeytype_config.py +++ /dev/null @@ -1,79 +0,0 @@ -""" -Monkeytype Configuration File -""" - -# isort: STDLIB -from typing import Any, Union - -# isort: THIRDPARTY -from monkeytype.config import DefaultConfig -from monkeytype.typing import ( - ChainedRewriter, - RemoveEmptyContainers, - RewriteConfigDict, - RewriteGenerator, - RewriteLargeUnion, - TypeRewriter, -) - - -class CanonicalizeUnionElementOrder(TypeRewriter): - """ - Monkeytype type rewriter to sort union elements in canonical order. - """ - - @staticmethod - def type_order(typ) -> str: - """ - Return a value to be used as a key for sorting. - """ - - print(f"BIG: {typ}", flush=True) - if typ is Any: - return "Any" - - try: - under_name = typ._name # pylint: disable=protected-access - except AttributeError: - under_name = None - - try: - dunder_name = typ.__name__ - except AttributeError: - dunder_name = None - - return ( - under_name - if under_name is not None - else (dunder_name if dunder_name is not None else "") - ) - - def rewrite_Union(self, union): - return Union[ - tuple( - sorted( - list(union.__args__), - key=CanonicalizeUnionElementOrder.type_order, - ) - ) - ] - - -class MyConfig(DefaultConfig): - """ - Monkeytype configuration for this project - """ - - def type_rewriter(self): - return ChainedRewriter( - ( - RemoveEmptyContainers(), - RewriteConfigDict(), - RewriteLargeUnion(), - RewriteGenerator(), - CanonicalizeUnionElementOrder(), - ) - ) - - -CONFIG = MyConfig()