Giter Club home page Giter Club logo

action-mypy's Introduction

action-mypy's People

Contributors

bernhardkaindl avatar github-actions[bot] avatar milly avatar renovate-bot avatar renovate[bot] avatar sjust-seerbio avatar tsuyoshicho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

action-mypy's Issues

Next major release

  • Change default option value

    • setup_method: nothing
      • install support specific version
    • ignore_note: enable
  • Change internal function

    • automatic install stub
      need preflight running(generate cache) and run as follow command
      mypy --install-types --non-interactive
      
      default on option

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>whitesource/merge-confidence:beta)

Some mypy errors are ignored

I have a mypy error that looks like this:

importer/flows/helpers/__init__.py: error: Duplicate module named "helpers" (also at "<snip>")

Currently this gets ignored because it doesn't have the line and column numbers that -efm="%f:%l:%c: %t%*[^:]: %m" expects.

Tentatively winnielabs@42d4817 fixes this, but I haven't really tested this thoroughly to see what other effects that has.

I'm suspecting that if mypy gets json output (as per #38), then that would fix this as well. But the upstream PR is a year old now and there's no decision-making from the core mypy team about what would be needed for it to get merged, so I'm not hopeful about that happening soon.

Type checking with third party packages

I have a project with multiple dependencies from PyPI. How can I use this such that mypy will find my dependencies? Installing into the virtualenv provided by actions/setup-python@v2 doesn't help.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/depup.yml
  • actions/checkout v4
  • haya14busa/action-depup v1
  • peter-evans/create-pull-request v6
.github/workflows/release-check.yml
  • actions/checkout v4
  • haya14busa/action-bumpr v1
.github/workflows/release.yml
  • actions/checkout v4
  • haya14busa/action-bumpr v1
  • haya14busa/action-update-semver v1
  • haya14busa/action-cond v1
  • softprops/action-gh-release v2
.github/workflows/reviewdog.yml
  • actions/checkout v4
  • haya14busa/action-cond v1
  • reviewdog/action-shellcheck v1
  • actions/checkout v4
  • reviewdog/action-misspell v1
  • actions/checkout v4
  • reviewdog/action-alex v1
.github/workflows/test.yml
  • actions/checkout v4
  • actions/setup-python v5
  • actions/checkout v4
  • actions/setup-python v5
  • actions/checkout v4
  • actions/setup-python v5
  • actions/checkout v4
  • actions/setup-python v5
  • actions/checkout v4
  • actions/setup-python v5
.github/workflows/update_semver.yml
  • actions/checkout v4
  • haya14busa/action-update-semver v1
pip_requirements
requirements.txt
  • mypy ==1.9.0
testdata/requirements.txt
  • build ==1.2.1
  • certifi ==2024.2.2
  • charset-normalizer ==3.3.2
  • click ==8.1.7
  • colorama ==0.4.6
  • idna ==3.6
  • packaging ==24.0
  • pip-tools ==7.4.1
  • pyproject-hooks ==1.0.0
  • requests ==2.31.0
  • urllib3 ==2.2.1
  • wheel ==0.43.0
testerror/requirements.txt
  • build ==1.2.1
  • certifi ==2024.2.2
  • charset-normalizer ==3.3.2
  • click ==8.1.7
  • colorama ==0.4.6
  • idna ==3.6
  • packaging ==24.0
  • pip-tools ==7.4.1
  • pyproject-hooks ==1.0.0
  • requests ==2.31.0
  • urllib3 ==2.2.1
  • wheel ==0.43.0
pyenv
.python-version
  • python 3.12.2

  • Check this box to trigger a request for Renovate to run again on this repository

Suggestion: Allow user to choose mypy version manually

Sometimes people may not want to use the latest mypy for testing, because mypy can change its type checking output format (for example, Tuple[...] is changed to tuple[...] in 1.4, and Union[a, b] becomes a | b) . People who run automatic test suite would want to pin to a very specific mypy version.

Indeed, it is possible to pin to a specific action-mypy commit in GitHub workflow instead, but that also means people are unable to use any new features in latest action-mypy.

To be concise, I mean something like:

- name: workflow name
  uses: tsuyoshicho/action-mypy@v3
  with:
    mypy_version: '1.2.0'

Feature request: Multiple targets for mypy

Hi @tsuyoshicho, first of all, thank you for this very useful action!

I had a little problem using it in my GitHub workflow because it only supports a single target at the moment. I tried putting multiple files separated by white space in the target input of the action (like file1 file2), but I saw that this line quotes the target and therefore mypy looks for a single file (or directory) with the name file1 file2, i.e., containing the white space.

The context of why I'd like to do this is that I identify the changed or added files in a pull request using the GitHub action dorny/paths-filter. It supports outputting all changed files in a shell-like list, i.e., with white space as delimiter. I'd like mypy to only lint the changed/added files and not the whole repository because linting issues that weren't introduced by the current PR shouldn't block it from being merged.
As a workaround, I tried setting target to "" and putting the list of files in the mypy flags input. Unfortunately, that doesn't work either because then the default value of "." is inserted in the same line I linked above.

Do you think your action could support this use case?

"Running mypy with reviewdog 🐶 ..." does not comment and shows no error, despite errors.

I run into the same issue as the 2nd issue reported in #111:

Second, the step "Running mypy with reviewdog 🐶 ..." shows no output and passes without errors, even when there are typing errors in the project:

I enabled mypy --verbose and see that mypy is issuing two warnings for a file (it mentions two times that it has a warning about a place in the file), in the step "Running mypy with reviewdog 🐶 ...", but the action hides the actual errors and does not add a comment to the PR.

Custom MyPy binary

When installing dependencies with Poetry, the mypy ... command is not available and instead one should use poetry run mypy ....

It would be nice to be able to add an option for the binary used for the mypy invocation (and potentially an option to skip installing mypy without checking if it is installed).

Multiple reviews generated for multiline mypy error

I'm using action with following step configuration:

    - name: Mypy review
      uses: tsuyoshicho/action-mypy@v3
      with:
        reporter: github-pr-review
        level: warning
        fail_on_error: true

As an example, following is a multi-line mypy error when overriding superclass property in an incompatible way:

/home/runner/.../file.pyi:28:6: error: Signature of "error_log" incompatible with supertype "_Validator"
/home/runner/.../file.pyi:28:6: note:      Superclass:
/home/runner/.../file.pyi:28:6: note:          def error_log(self) -> _ErrorLog
/home/runner/.../file.pyi:28:6: note:      Subclass:
/home/runner/.../file.pyi:28:6: note:          @overload
/home/runner/.../file.pyi:28:6: note:          def error_log(self) -> int
/home/runner/.../file.pyi:29:5: error: Return type "int" of "error_log" incompatible with return type "_ErrorLog" in supertype "_Validator"

The error came from a single diff hunk, so I was expecting a single reviewdog action. Instead, it generated 7 independent reviews on the same pull request, each containing one line, and all of them are attached to the same diff.

one >53 errrors to report, reviewdog aborts GitHubActionLogWriter: "reported too many annotation"

TODO / Remaining bug:

When more than 53 errors are reported by mypy and are not filtered, reviewdog gives up and aborts with the message:

GitHubActionLogWriter: "reported too many annotation"

The error is buried in the middle of the long output:

  /home/runner/work/xen-api/xen-api/scripts/plugins/extauth-hook-AD.py:70:19: error: If x = b'abc' then f"{x}" or "{}".format(x) produces "b'abc'", not "abc". If this is desired behavior, use f"{x!r}" or "{!r}".format(x). Otherwise, decode the bytes  [str-bytes-safe]
  Warning: [mypy] reported by reviewdog 🐶
  In function "fresh_name":
  
  Raw Output:
  /home/runner/work/xen-api/xen-api/scripts/static-vdis: note: In function "fresh_name":
  reviewdog: GitHubActionLogWriter: reported too many annotation (N=53)
  + reviewdog_exit_val=1
  + echo ::endgroup::
  + [[ false == \t\r\u\e ]]
  Error: [mypy] reported by reviewdog 🐶
  Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
  
  Raw Output:

I know the current GitHub limits, they are also printed in the log:

   Error: reviewdog: Too many results (annotations) in diff.
  You may miss some annotations due to GitHub limitation for annotation created by logging command.
  Please check GitHub Actions log console to see all results.
  
  Limitation:
  - 10 warning annotations and 10 error annotations per step
  - 50 annotations per job (sum of annotations from all the steps)
  - 50 annotations per run (separate from the job annotations, these annotations aren't created by users)

However, reviewdog should do it's best to report 10 error annotations and 10 warning annotations (and it should also support 10 notice annotations, btw) and if > 10 annotations, the 10th annotation of each kind should be a message that there are more than 10 annotations, which GitHub does not support.

The same may also apply to review comments, but I am not aware of such limit. However, to prevent a DoS from reviewdog, it is likely best if reviewdog replaces the last comment it would be able to add with a "Giving up due to GitHub limit".

In case of too many errors, it may also be nice to merge several erros of the same kind into one error and add "more of the same are omitted due to GitHub annotation limits of 10 annotations per type and step".

Another nice feature would be to mark less important errors not as errors but as warings and notices, so in total 30 annotations could be issued per step.

The biggest problem is that the action-mypy does not fail CI in this case, so the error goes unnoticed:

https://github.com/xenserver-next/xen-api/actions/runs/7706543512/job/21002295649

Running via Poetry doesn't seem to work

Hello,

Per the README, I'm using

      - name: Run mypy
        uses: tsuyoshicho/action-mypy@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          reporter: github-pr-review
          # level: warning
          execute_command: 'poetry run mypy'

(I also tried setting the execute_command to poetry run mypy . -- which is actually what I'd use to run it at my shell)

This resulted in the following run:

image

which seems to report that all is OK, but in reality, running the command at my shell in the project folder on that same ref gives of around 6 errors.

$ poetry run mypy . 
htrc/ef/api.py:62: error: Incompatible types in assignment (expression has type "Optional[Dict[Any, Any]]", variable has type "Dict[Any, Any]")  [assignment]
htrc/ef/api.py:77: error: Item "None" of "Optional[Dict[Any, Any]]" has no attribute "__iter__" (not iterable)  [union-attr]
htrc/ef/api.py:87: error: Item "None" of "Optional[Dict[Any, Any]]" has no attribute "__iter__" (not iterable)  [union-attr]
htrc/ef/api.py:108: error: Item "None" of "Optional[Dict[Any, Any]]" has no attribute "__iter__" (not iterable)  [union-attr]
htrc/torchlite/worksets.py:29: error: Incompatible types in assignment (expression has type "Optional[Workset]", variable has type "Workset")  [assignment]
htrc/torchlite/worksets.py:42: error: Incompatible return value type (got "Optional[List[Volume]]", expected "List[Volume]")  [return-value]
Found 6 errors in 2 files (checked 16 source files)

Deps are not installed

Hi, I try to use the actual action to perform the mypy one, but it didn't works because the actual setup does not install the packages deps, are least no with a pure pyproject.toml, which means there is no requirements.txt.

name: reviewdog
on: [pull_request]
jobs:
  mypy:
    name: runner / mypy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: tsuyoshicho/action-mypy@v3
        with:
          github_token: ${{ secrets.github_token }}
          # Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review].
          reporter: github-pr-review
          # Change reporter level if you need.
          # GitHub Status Check won't become failure with warning.
          level: warning
          # Change the current directory to run mypy command.
          # mypy command reads setup.cfg or other settings file in this path.
          workdir: src
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "test"
version = "01.23.01.2024"
dependencies = [
  "pandas",
  "pandas-stubs",
  "pyarrow", #https://github.com/pandas-dev/pandas/issues/54466
  "sqlalchemy",
  "scipy",
  "numpy",
  "matplotlib",
  "mypy"
]
description = "spam spam!"
readme = "README.md"

I got similar to this ones:

Library stubs not installed for "pandas" [import-untyped]

Thx!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.