diff --git a/.github/workflows/analyze-modified-files.yml b/.github/workflows/analyze-modified-files.yml new file mode 100644 index 00000000..7e5da43a --- /dev/null +++ b/.github/workflows/analyze-modified-files.yml @@ -0,0 +1,75 @@ +name: Analyze modified files + +on: + pull_request: + paths: + - "**.py" + push: + paths: + - "**.py" + +env: + BASE: ${{ github.event.pull_request.base.sha }} + HEAD: ${{ github.event.pull_request.head.sha }} + BEFORE: ${{ github.event.before }} + AFTER: ${{ github.event.after }} + +jobs: + flake8-or-mypy: + strategy: + fail-fast: false + matrix: + task: [flake8, mypy] + + name: ${{ matrix.task }} + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: "Determine modified files (pull_request)" + if: github.event_name == 'pull_request' + run: | + git fetch origin $BASE $HEAD + DIFF=$(git diff --diff-filter=d --name-only $BASE...$HEAD -- "*.py") + echo "modified files:" + echo "$DIFF" + echo "diff=${DIFF//$'\n'/$' '}" >> $GITHUB_ENV + + - name: "Determine modified files (push)" + if: github.event_name == 'push' + run: | + git fetch origin $BEFORE $AFTER + DIFF=$(git diff --diff-filter=d --name-only $BEFORE..$AFTER -- "*.py") + echo "modified files:" + echo "$DIFF" + echo "diff=${DIFF//$'\n'/$' '}" >> $GITHUB_ENV + + - uses: actions/setup-python@v4 + if: env.diff != '' + with: + python-version: 3.8 + + - name: "Install dependencies" + if: env.diff != '' + run: | + python -m pip install --upgrade pip ${{ matrix.task }} + python ModuleUpdate.py --append "WebHostLib/requirements.txt" --force --yes + + - name: "flake8: Stop the build if there are Python syntax errors or undefined names" + continue-on-error: false + if: env.diff != '' && matrix.task == 'flake8' + run: | + flake8 --count --select=E9,F63,F7,F82 --show-source --statistics ${{ env.diff }} + + - name: "flake8: Lint modified files" + continue-on-error: true + if: env.diff != '' && matrix.task == 'flake8' + run: | + flake8 --count --max-complexity=10 --max-doc-length=120 --max-line-length=120 --statistics ${{ env.diff }} + + - name: "mypy: Type check modified files" + continue-on-error: true + if: env.diff != '' && matrix.task == 'mypy' + run: | + mypy --follow-imports=silent --install-types --non-interactive --strict ${{ env.diff }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index c20d244a..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,35 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: lint - -on: - push: - paths: - - '**.py' - pull_request: - paths: - - '**.py' - -jobs: - flake8: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - name: Install dependencies - run: | - python -m pip install --upgrade pip wheel - pip install flake8 - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics diff --git a/AdventureClient.py b/AdventureClient.py index 0977203e..d2f4e734 100644 --- a/AdventureClient.py +++ b/AdventureClient.py @@ -396,7 +396,7 @@ async def atari_sync_task(ctx: AdventureContext): ctx.atari_streams = await asyncio.wait_for( asyncio.open_connection("localhost", port), - timeout=10) + timeout=10) ctx.atari_status = CONNECTION_TENTATIVE_STATUS except TimeoutError: logger.debug("Connection Timed Out, Trying Again") diff --git a/worlds/adventure/__init__.py b/worlds/adventure/__init__.py index a914c8d9..eba887a6 100644 --- a/worlds/adventure/__init__.py +++ b/worlds/adventure/__init__.py @@ -57,7 +57,7 @@ class AdventureWeb(WebWorld): def get_item_position_data_start(table_index: int): - item_ram_address = item_ram_addresses[table_index]; + item_ram_address = item_ram_addresses[table_index] return item_position_table + item_ram_address - items_ram_start diff --git a/worlds/alttp/Regions.py b/worlds/alttp/Regions.py index 3f3644c4..9badbd87 100644 --- a/worlds/alttp/Regions.py +++ b/worlds/alttp/Regions.py @@ -1175,4 +1175,4 @@ lookup_vanilla_location_to_entrance = { } lookup_prizes = {location for location in location_table if location.endswith(" - Prize")} -lookup_boss_drops = {location for location in location_table if location.endswith(" - Boss")} \ No newline at end of file +lookup_boss_drops = {location for location in location_table if location.endswith(" - Boss")}