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

Fixes for markdown stubs #4758

Merged
merged 6 commits into from
Nov 13, 2020
Merged

Fixes for markdown stubs #4758

merged 6 commits into from
Nov 13, 2020

Conversation

andersk
Copy link
Contributor

@andersk andersk commented Nov 10, 2020

  • Remove members inherited from base classes
  • Add missing markdown.Extension alias
  • Add missing Markdown members
  • Fix Extension.config type
  • Fix Pattern.handleMatch type

Cc: @erictraut @hauntsaninja @hynek @silasary

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@andersk
Copy link
Contributor Author

andersk commented Nov 10, 2020

Regrading mypy_primer—I’m from the Zulip team, working on fixing these zerver/lib/markdown errors. This requires fixes in both Zulip and typeshed.

@hauntsaninja
Copy link
Collaborator

I'm guessing pytype doesn't support the type ignore with error code

@andersk
Copy link
Contributor Author

andersk commented Nov 11, 2020

@hauntsaninja Reasonable guess. Fixed.

@rchen152
Copy link
Collaborator

I'm guessing pytype doesn't support the type ignore with error code

That seems like the right diagnosis to me. Might be as simple to fix as changing the typeginore definition here: https://github.com/google/pytype/blob/70215e185f17d2611ea4230eb1375c17712560fe/pytype/pyi/parser.yy#L572. I'll give that a try tomorrow.

@github-actions

This comment has been minimized.

rchen152 added a commit to google/pytype that referenced this pull request Nov 12, 2020
Came up in python/typeshed#4758 - mypy supports having
error codes in brackets after a `# type: ignore`. From
https://github.com/python/mypy/blob/master/mypy/errorcodes.py and
https://hub.packtpub.com/mypy-0-730-releases-with-more-precise-error-locations-display-error-codes/,
it seems error codes look like my-error-code, and you can include multiple
by separating them with commas.

This change will also allow `# type: ignore[]`, but I think that's fine.

PiperOrigin-RevId: 341947562
Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks! Remarks below.

third_party/2and3/markdown/__init__.pyi Outdated Show resolved Hide resolved
third_party/2and3/markdown/core.pyi Outdated Show resolved Hide resolved
third_party/2and3/markdown/extensions/__init__.pyi Outdated Show resolved Hide resolved
third_party/2and3/markdown/extensions/abbr.pyi Outdated Show resolved Hide resolved
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

- zerver/lib/markdown/tabbed_sections.py:163: error: Argument 1 to "TabbedSectionsGenerator" has incompatible type "**Dict[str, str]"; expected "Mapping[str, str]"  [arg-type]
- zerver/lib/markdown/api_arguments_table_generator.py:19: error: Dict entry 0 has incompatible type "str": "List[str]"; expected "str": "str"  [dict-item]
- zerver/lib/markdown/fenced_code.py:145: error: Dict entry 0 has incompatible type "str": "List[Any]"; expected "str": "str"  [dict-item]
- zerver/lib/markdown/fenced_code.py:158: error: Argument "run_content_validators" to "FencedBlockPreprocessor" has incompatible type "str"; expected "bool"  [arg-type]
- zerver/lib/markdown/__init__.py:527: error: Return type "Tuple[Optional[Element], int, int]" of "handleMatch" incompatible with return type "None" in supertype "InlineProcessor"  [override]
+ zerver/lib/markdown/__init__.py:527: error: Return type "Tuple[Optional[Element], int, int]" of "handleMatch" incompatible with return type "Union[Tuple[Element, int, int], Tuple[None, None, None]]" in supertype "InlineProcessor"  [override]
+ zerver/lib/markdown/__init__.py:535: error: Item "None" of "Optional[Element]" has no attribute "text"  [union-attr]
+ zerver/lib/markdown/__init__.py:536: error: Incompatible return value type (got "Tuple[Optional[Element], Optional[int], Optional[int]]", expected "Tuple[Optional[Element], int, int]")  [return-value]
- zerver/lib/markdown/__init__.py:1239: error: Return type "Optional[Element]" of "handleMatch" incompatible with return type "None" in supertype "Pattern"  [override]
- zerver/lib/markdown/__init__.py:1344: error: Return type "Optional[Element]" of "handleMatch" incompatible with return type "None" in supertype "Pattern"  [override]
- zerver/lib/markdown/__init__.py:1355: error: Return type "Optional[Element]" of "handleMatch" incompatible with return type "None" in supertype "Pattern"  [override]
- zerver/lib/markdown/__init__.py:1365: error: Return type "Optional[Element]" of "handleMatch" incompatible with return type "None" in supertype "Pattern"  [override]
- zerver/lib/markdown/__init__.py:1387: error: Return type "Element" of "handleMatch" incompatible with return type "None" in supertype "Pattern"  [override]
- zerver/lib/markdown/__init__.py:1488: error: Return type "Union[Element, str, None]" of "handleMatch" incompatible with return type "None" in supertype "Pattern"  [override]
- zerver/lib/markdown/__init__.py:1652: error: Return type "Union[Element, str]" of "handleMatch" incompatible with return type "None" in supertype "Pattern"  [override]
- zerver/lib/markdown/__init__.py:1659: error: Return type "Optional[Element]" of "handleMatch" incompatible with return type "None" in supertype "Pattern"  [override]
- zerver/lib/markdown/__init__.py:1704: error: Return type "Optional[Element]" of "handleMatch" incompatible with return type "None" in supertype "Pattern"  [override]
- zerver/lib/markdown/__init__.py:1736: error: Return type "Optional[Element]" of "handleMatch" incompatible with return type "None" in supertype "Pattern"  [override]
- zerver/lib/markdown/__init__.py:1766: error: Return type "Optional[Element]" of "handleMatch" incompatible with return type "None" in supertype "Pattern"  [override]
- zerver/lib/markdown/__init__.py:1855: error: Return type "Tuple[Optional[Element], int, int]" of "handleMatch" incompatible with return type "None" in supertype "InlineProcessor"  [override]
+ zerver/lib/markdown/__init__.py:1855: error: Return type "Tuple[Optional[Element], int, int]" of "handleMatch" incompatible with return type "Union[Tuple[Element, int, int], Tuple[None, None, None]]" in supertype "InlineProcessor"  [override]
- zerver/lib/markdown/nested_code_blocks.py:75: error: Argument 1 to "NestedCodeBlocksRenderer" has incompatible type "**Dict[str, str]"; expected "Mapping[str, str]"  [arg-type]
+ zerver/lib/markdown/__init__.py:1859: error: Incompatible return value type (got "Tuple[Optional[Element], Optional[int], Optional[int]]", expected "Tuple[Optional[Element], int, int]")  [return-value]

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks, one request for future reference: Please don't force push changes after review as it makes it harder to re-review changes. We squash merge in typeshed anyway.

@srittau srittau merged commit 536a5c6 into python:master Nov 13, 2020
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.

4 participants