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

Add mypy checks #5150

Merged
merged 31 commits into from
Jan 10, 2020
Merged

Add mypy checks #5150

merged 31 commits into from
Jan 10, 2020

Conversation

IKarbowiak
Copy link
Member

@IKarbowiak IKarbowiak commented Jan 9, 2020

Add mypy to CI and pre-commit checks. Fix mypy errors.
Closes #4720

Pull Request Checklist

  1. Privileged views and APIs are guarded by proper permission checks.
  2. All visible strings are translated with proper context.
  3. All data-formatting is locale-aware (dates, numbers, and so on).
  4. Database queries are optimized and the number of queries is constant.
  5. Database migration files are up to date.
  6. The changes are tested.
  7. GraphQL schema and type definitions are up to date.
  8. Changes are mentioned in the changelog.

@IKarbowiak IKarbowiak self-assigned this Jan 9, 2020
@codecov
Copy link

codecov bot commented Jan 9, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@7964037). Click here to learn what that means.
The diff coverage is 97.5%.

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #5150   +/-   ##
========================================
  Coverage          ?   91.7%           
========================================
  Files             ?     260           
  Lines             ?   16838           
  Branches          ?    1482           
========================================
  Hits              ?   15442           
  Misses            ?    1008           
  Partials          ?     388
Impacted Files Coverage Δ
saleor/graphql/order/schema.py 100% <ø> (ø)
saleor/graphql/utils.py 89.89% <ø> (ø)
saleor/graphql/product/types/attributes.py 98.01% <ø> (ø)
saleor/graphql/menu/types.py 89.74% <ø> (ø)
saleor/graphql/checkout/schema.py 100% <ø> (ø)
saleor/graphql/account/mutations/staff.py 97.02% <ø> (ø)
saleor/product/utils/availability.py 97.61% <ø> (ø)
saleor/core/middleware.py 52.5% <ø> (ø)
saleor/graphql/account/mutations/base.py 98.66% <ø> (ø)
saleor/graphql/menu/schema.py 100% <ø> (ø)
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7964037...64541ac. Read the comment docs.

Copy link

django-queries commented Jan 9, 2020

Here is the report for 64541ac (mirumee/saleor @ add-mypy-checks)
Base comparison is 9ac4ee9.

No differences were found. (click me)

# api.benchmark checkout
  test name                                  	left count 	right count	duplicate count
  -------------------------------------------	-----------	-----------	---------------
  add billing address to checkout            	         34	         34	             20
  add shipping to checkout                   	          7	          7	              0
  checkout payment charge                    	         10	         10	              0
  complete checkout                          	          8	          8	              0
  create checkout                            	         50	         50	             24

# api.benchmark homepage
  test name                                  	left count 	right count	duplicate count
  -------------------------------------------	-----------	-----------	---------------
  retrieve main menu                         	          5	          5	              0
  retrieve product list                      	          4	          4	              0
  retrieve secondary menu                    	          5	          5	              0
  retrieve shop                              	          2	          2	              0

# api.benchmark product
  test name                                  	left count 	right count	duplicate count
  -------------------------------------------	-----------	-----------	---------------
  product details                            	         14	         14	              2
  retrieve product attributes                	          9	          9	              0

# api.benchmark variant
  test name                                  	left count 	right count	duplicate count
  -------------------------------------------	-----------	-----------	---------------
  product variant bulk create                	         51	         51	              3
  retrieve variant list                      	         16	         16	              6

# api product sorting attributes
  test name                                  	left count 	right count	duplicate count
  -------------------------------------------	-----------	-----------	---------------
  sort product not having attribute data     	         21	         21	              0

@IKarbowiak
Copy link
Member Author

Some clarification:

  1. I was trying to avoid # type: ignore annotation, but it wasn't possible in all places. For example mypy doesn't take into account hasattr. There are tickets about that on their github so maybe it'll be resolved soon. Type inference and hasattr python/mypy#1424 Take into account the results of hasattr()/dir(), similarly to isinstance and so on… python/mypy#4944
  2. Instead of just # type: ignore I wanted to specified code error like: # type: ignore[attr-defined] but the flake8 has problem with that and I can't find solution.
    image

@maarcingebala
Copy link
Member

I guess it's fine to have those # type: ignore occurrences in a few places if we can't do anything about it.

Copy link
Member

@krzysztofwolski krzysztofwolski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪 lots of improvements!

@maarcingebala maarcingebala merged commit e09d62b into master Jan 10, 2020
@maarcingebala maarcingebala deleted the add-mypy-checks branch January 10, 2020 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable mypy on CI
4 participants