Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

[CI] Enable type checks and inference with pytype #1018

Merged
merged 9 commits into from
Nov 28, 2019
Merged

Conversation

leezu
Copy link
Contributor

@leezu leezu commented Nov 21, 2019

Description

Pytype is a static type analyzer for Python code.

Pytype checks and infers types for your Python code - without requiring type annotations. Pytype can:

  • Lint plain Python code, flagging common mistakes such as misspelled attribute names, incorrect function calls, and much more, even across file boundaries.
  • Enforce user-provided type annotations. While annotations are optional for pytype, it will check and apply them where present.
  • Generate type annotations in standalone files ("pyi files"), which can be merged back into the Python source with a provided merge-pyi tool.

Pytype is a static analyzer; it does not execute the code it runs on.

Checklist

Essentials

  • PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented

Changes

  • Enable type checks and inference with pytype

Comments

Later we can use the merge-pyi to integrate the inferred types into the codebase.

cc @dmlc/gluon-nlp-team

typing.NamedTuple is not a generic type that can be used as type annotation.
Rather it's intended usage is for users to instantiate a specific NamedTuple
class, which can then be used for typechecking.
@leezu leezu requested a review from a team as a code owner November 21, 2019 04:14
@codecov
Copy link

codecov bot commented Nov 21, 2019

Codecov Report

Merging #1018 into master will decrease coverage by 0.02%.
The diff coverage is 97.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1018      +/-   ##
==========================================
- Coverage   89.93%   89.91%   -0.03%     
==========================================
  Files          67       67              
  Lines        6340     6333       -7     
==========================================
- Hits         5702     5694       -8     
- Misses        638      639       +1
Impacted Files Coverage Δ
src/gluonnlp/metric/__init__.py 100% <100%> (ø) ⬆️
src/gluonnlp/base.py 86.2% <100%> (ø) ⬆️
src/gluonnlp/data/batchify/batchify.py 95.27% <100%> (ø) ⬆️
src/gluonnlp/data/batchify/__init__.py 100% <100%> (ø) ⬆️
src/gluonnlp/loss/__init__.py 100% <100%> (ø) ⬆️
src/gluonnlp/data/conll.py 100% <100%> (ø) ⬆️
src/gluonnlp/vocab/vocab.py 95.4% <100%> (ø) ⬆️
src/gluonnlp/data/batchify/embedding.py 97.58% <100%> (-0.12%) ⬇️
src/gluonnlp/optimizer/__init__.py 100% <100%> (ø) ⬆️
src/gluonnlp/embedding/__init__.py 100% <100%> (ø) ⬆️
... and 10 more

@leezu leezu force-pushed the pytype branch 6 times, most recently from dfaa63b to 3290eb0 Compare November 21, 2019 07:11
@mli
Copy link
Member

mli commented Nov 21, 2019

Job PR-1018/10 is complete.
Docs are uploaded to http://gluon-nlp-staging.s3-accelerate.dualstack.amazonaws.com/PR-1018/10/index.html

@leezu leezu merged commit 297e147 into dmlc:master Nov 28, 2019
@leezu leezu deleted the pytype branch November 28, 2019 04:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants