Skip to content

Commit

Permalink
(v3) Draft PR: add Pyright static typing to hook_points.py #590 (#607)
Browse files Browse the repository at this point in the history
* Initial Commit (add pyright + test by adding few annotations)

* Slightly more typing added

* more typing

* Additional typing

* Completed typing for hook_points.py file

* todo clarifications

* formatting changes to hook_points.py

* Apply some suggestions from code review

Co-authored-by: Alan <[email protected]>

* Added typing for Literals and changed some assertions to if statements

* formatting

* update to accout for merged code

* small typing issue

* changing hookfunction protocol + more assertions

* change the slice input

* change from isinstance to callable checks

* fix: Update Gemma to reflect upstream HF changes (#596)

* update activation function to tanh approximation

* keep RMSNorm calcs in float32 and match cfg dtype for embedding scaling

* formatting

* keep mypy happy

* formatting

* allow user to force trust_remote_code=true via from_pretrained kwargs (#597)

* change + revert HookFunctionProtocol

* format

* module_output is now just a tensor

* set module ouput to be any type

---------

Co-authored-by: Alan <[email protected]>
Co-authored-by: Bryce Meyer <[email protected]>
Co-authored-by: cmathw <[email protected]>
Co-authored-by: Clement Dumas <[email protected]>
  • Loading branch information
5 people authored May 24, 2024
1 parent 3c3d3a2 commit 295aca5
Show file tree
Hide file tree
Showing 2 changed files with 205 additions and 65 deletions.
65 changes: 65 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,68 @@
[build-system]
build-backend="poetry.core.masonry.api"
requires=["poetry-core"]

[tool.pyright]
# All rules apart from base are shown explicitly below
deprecateTypingAliases=true
disableBytesTypePromotions=true
exclude = [
"*/**/*.py",
"!/transformer_lens/hook_points.py"
]
reportAssertAlwaysTrue=true
reportConstantRedefinition=true
reportDeprecated=true
reportDuplicateImport=true
reportFunctionMemberAccess=true
reportGeneralTypeIssues=true
reportIncompatibleMethodOverride=true
reportIncompatibleVariableOverride=true
reportIncompleteStub=true
reportInconsistentConstructor=true
reportInvalidStringEscapeSequence=true
reportInvalidStubStatement=true
reportInvalidTypeVarUse=true
reportMatchNotExhaustive=true
reportMissingParameterType=true
reportMissingTypeArgument=false
reportMissingTypeStubs=false
reportOptionalCall=true
reportOptionalContextManager=true
reportOptionalIterable=true
reportOptionalMemberAccess=true
reportOptionalOperand=true
reportOptionalSubscript=true
reportOverlappingOverload=true
reportPrivateImportUsage=true
reportPrivateUsage=true
reportSelfClsParameterName=true
reportTypeCommentUsage=true
reportTypedDictNotRequiredAccess=true
reportUnboundVariable=true
reportUnknownArgumentType=false
reportUnknownLambdaType=true
reportUnknownMemberType=false
reportUnknownParameterType=false
reportUnknownVariableType=false
reportUnnecessaryCast=true
reportUnnecessaryComparison=true
reportUnnecessaryContains=true
reportUnnecessaryIsInstance=true
reportUnsupportedDunderAll=true
reportUntypedBaseClass=true
reportUntypedClassDecorator=true
reportUntypedFunctionDecorator=true
reportUntypedNamedTuple=true
reportUnusedClass=true
reportUnusedCoroutine=true
reportUnusedExpression=true
reportUnusedFunction=true
reportUnusedImport=true
reportUnusedVariable=true
reportWildcardImportFromLibrary=true
strictDictionaryInference=true
strictListInference=true
strictParameterNoneValue=true
strictSetInference=true

Loading

0 comments on commit 295aca5

Please sign in to comment.