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 validating_code_block typecheck errors #1949

Closed
wants to merge 1 commit into from

Conversation

mmorel-35
Copy link
Collaborator

@mmorel-35 mmorel-35 commented Mar 16, 2024

@phlax ,

I'm not extremely familiar with python so I prefer to check with you
The test_extensions.py / test_ext_validating_code_block_vbc_constructor is still passing.
I believe that fixes the typecheck error or am I missing something ?

Copy link

netlify bot commented Mar 16, 2024

Deploy Preview for nifty-bassi-e26446 ready!

Name Link
🔨 Latest commit 18fee18
🔍 Latest deploy log https://app.netlify.com/sites/nifty-bassi-e26446/deploys/65f54c99339649000815b29a
😎 Deploy Preview https://deploy-preview-1949--nifty-bassi-e26446.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mmorel-35 mmorel-35 force-pushed the fix-typecheck branch 7 times, most recently from acaa847 to e3c3b1b Compare March 16, 2024 07:36
@mmorel-35 mmorel-35 changed the title Type of option_spec Fix validating_code_block typecheck errors Mar 16, 2024
@mmorel-35 mmorel-35 requested a review from phlax March 16, 2024 07:39
@mmorel-35 mmorel-35 marked this pull request as ready for review March 16, 2024 07:39
@@ -26,8 +26,7 @@ class ValidatingCodeBlock(CodeBlock):
required_arguments = CodeBlock.required_arguments
optional_arguments = CodeBlock.optional_arguments
final_argument_whitespace = CodeBlock.final_argument_whitespace
option_spec = {"type-name": directives.unchanged}
option_spec.update(CodeBlock.option_spec)
CodeBlock.option_spec.update({'type-name': directives.unchanged})
Copy link
Member

Choose a reason for hiding this comment

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

im not so familiar with validating code block - mostly we dont use it as it makes docs build a lot slower

my concern with this change is that its setting CodeBlock.option_spec for any subsequent usage

with python its generally an anti-pattern to use any mutable vars on the class - for this reason - other code can change/redefine it and its not obvious on the class (or for any other instantiations). Mutable vars are generally defined post-instantiation - either in __init__ or by returning a mutable var from a cached @property

in this case im surprised the Sphinx code allows it, but either way i think this is changing something it shouldnt

looking at the typing errors

envoy.docs.sphinx_runner/envoy/docs/sphinx_runner/ext/validating_code_block.py:29: error: Cannot override instance variable (previously declared on base class "CodeBlock") with class variable
envoy.docs.sphinx_runner/envoy/docs/sphinx_runner/ext/validating_code_block.py:30: error: Argument 1 to "update" of "MutableMapping" has incompatible type "Dict[str, Callable[[str], Any]]"; expected "SupportsKeysAndGetItem[str, Callable[[Optional[str]], str]]"

in not sure on cause or fix tbh

in particular im trying to understand why this is flaking on some PRs and not others

the underlying issue appears to be related to this python/typeshed#11550

Copy link
Member

Choose a reason for hiding this comment

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

... i see - its the mypy update PR that is failing here

Copy link
Member

Choose a reason for hiding this comment

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

also relevant sphinx-doc/sphinx#12067

Copy link
Member

Choose a reason for hiding this comment

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

iiuc this PR would still fail the newer mypy

Copy link
Member

Choose a reason for hiding this comment

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

just realizing that all prs are failing this which is strange

trying to understand what changed - it kinda shouldnt have started without some code change

either way we need to address it asap

Copy link
Member

Choose a reason for hiding this comment

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

checking again and we dont actually pin versions (kinda by design, but perhaps we should do so for external deps)

some are set by pants/mypy setup - not sure how they can be pinned

@mmorel-35 mmorel-35 closed this Mar 19, 2024
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.

2 participants