Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typing #165

Open
Abuelodelanada opened this issue Dec 5, 2024 · 0 comments
Open

Fix typing #165

Abuelodelanada opened this issue Dec 5, 2024 · 0 comments

Comments

@Abuelodelanada
Copy link
Contributor

Abuelodelanada commented Dec 5, 2024

Enhancement Proposal

This issue was found while working in this PR: #163
It was already opened in microsoft/pyright#9539

They say this is unlikely to be a bug in pyright

However, until version 1.1.381 everything was OK:

✗ tox -re static-charm
static-charm: remove tox env folder /home/jose/trabajos/canonical/repos/cos-proxy-operator/.tox/static-charm
static-charm: install_deps> python -I -m pip install httpcore==0.14.7 pyright==1.1.381 responses==0.20.0 -r /home/jose/trabajos/canonical/repos/cos-proxy-operator/requirements.txt
static-charm: commands[0]> pyright /home/jose/trabajos/canonical/repos/cos-proxy-operator/src
WARNING: there is a new pyright version available (v1.1.381 -> v1.1.389).
Please install the new version or set PYRIGHT_PYTHON_FORCE_VERSION to `latest`

0 errors, 0 warnings, 0 informations 
  static-charm: OK (60.07=setup[43.68]+cmd[16.39] seconds)
  congratulations :) (60.61 seconds)

But with 1.1.382+ I see these errors:

✗ tox -e static-charm 
static-charm: commands[0]> pyright /home/jose/trabajos/canonical/repos/cos-proxy-operator/src
WARNING: there is a new pyright version available (v1.1.382 -> v1.1.389).
Please install the new version or set PYRIGHT_PYTHON_FORCE_VERSION to `latest`

/home/jose/trabajos/canonical/repos/cos-proxy-operator/src/charm.py
  /home/jose/trabajos/canonical/repos/cos-proxy-operator/src/charm.py:309:37 - error: Argument missing for parameter "static_configs" (reportCallIssue)
  /home/jose/trabajos/canonical/repos/cos-proxy-operator/src/charm.py:309:54 - error: Argument expression after ** must be a mapping with a "str" key type (reportCallIssue)
  /home/jose/trabajos/canonical/repos/cos-proxy-operator/src/charm.py:330:38 - error: Arguments missing for parameters "name", "rules" (reportCallIssue)
  /home/jose/trabajos/canonical/repos/cos-proxy-operator/src/charm.py:330:56 - error: Argument expression after ** must be a mapping with a "str" key type (reportCallIssue)
  /home/jose/trabajos/canonical/repos/cos-proxy-operator/src/charm.py:639:64 - error: Argument of type "str | list[Unknown] | dict[Any, Any] | Unknown | Any" cannot be assigned to parameter "job_name" of type "str" in function "remove_prometheus_jobs"
    Type "str | list[Unknown] | dict[Any, Any] | Unknown | Any" is not assignable to type "str"
      "dict[Any, Any]" is not assignable to "str" (reportArgumentType)
  /home/jose/trabajos/canonical/repos/cos-proxy-operator/src/charm.py:664:35 - error: No overloads for "__getitem__" match the provided arguments (reportCallIssue)
  /home/jose/trabajos/canonical/repos/cos-proxy-operator/src/charm.py:664:35 - error: Argument of type "Literal['labels']" cannot be assigned to parameter "s" of type "slice" in function "__getitem__"
    "Literal['labels']" is not assignable to "slice" (reportArgumentType)
  /home/jose/trabajos/canonical/repos/cos-proxy-operator/src/charm.py:665:17 - error: Argument of type "Dict[str, Any] | list[Unknown] | dict[Any, Any] | Unknown | Any" cannot be assigned to parameter "unit_rules" of type "dict[Unknown, Unknown]" in function "set_alert_rule_data"
    Type "Dict[str, Any] | list[Unknown] | dict[Any, Any] | Unknown | Any" is not assignable to type "dict[Unknown, Unknown]"
      "list[Unknown]" is not assignable to "dict[Unknown, Unknown]" (reportArgumentType)
8 errors, 0 warnings, 0 informations 
static-charm: exit 1 (15.58 seconds) /home/jose/trabajos/canonical/repos/cos-proxy-operator> pyright /home/jose/trabajos/canonical/repos/cos-proxy-operator/src pid=719891
  static-charm: FAIL code 1 (15.73=setup[0.15]+cmd[15.58] seconds)
  evaluation failed :( (16.31 seconds)

Context

For the first 2 errors (line 309)

Image

job_data is a dictionary generated by the method _static_scrape_job that has the static_configs key:

Image

The ScrapeJobModel class is pydantic BaseModel that looks like:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant