Skip to content

feat[tool]: add -Werror and -Wnone options#4447

Merged
charles-cooper merged 24 commits intovyperlang:masterfrom
charles-cooper:feat/warnings-filter
Feb 21, 2025
Merged

feat[tool]: add -Werror and -Wnone options#4447
charles-cooper merged 24 commits intovyperlang:masterfrom
charles-cooper:feat/warnings-filter

Conversation

@charles-cooper
Copy link
Copy Markdown
Member

@charles-cooper charles-cooper commented Jan 12, 2025

What I did

How I did it

How to verify it

Commit message

this commit adds `-Werror` and `-Wnone` CLI flags which promote
warnings to errors and ignore them, respectively.

also adds some small refactoring for warning handling to simplify the
implementation (allow us to use warnings.simplefilter). this provides
a way moving forward to do fine-grained warnings control, since the
warnings filter allows us to use the exception class in the filter.

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

which promote warnings to errors and ignore them, respectively.

also some small refactoring for warning handling to simplify the
implementation (allow us to use `warnings.simplefilter`).
@charles-cooper charles-cooper changed the title add -Werror and -Wnone options feat[tool]: add -Werror and -Wnone options Jan 12, 2025
@charles-cooper charles-cooper changed the title feat[tool]: add -Werror and -Wnone options feat[tool]: add -Werror and -Wnone options Jan 12, 2025
from typing import Generic, List, TypeVar, Union

from vyper.exceptions import CompilerPanic, DecimalOverrideException, VyperException
from vyper.exceptions import CompilerPanic, DecimalOverrideException

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
vyper.exceptions
begins an import cycle.
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 12, 2025

Codecov Report

Attention: Patch coverage is 98.52941% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.06%. Comparing base (9e396fb) to head (1db85b8).
Report is 97 commits behind head on master.

Files with missing lines Patch % Lines
vyper/compiler/phases.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4447      +/-   ##
==========================================
- Coverage   92.12%   92.06%   -0.06%     
==========================================
  Files         119      120       +1     
  Lines       16962    17329     +367     
  Branches     2872     2932      +60     
==========================================
+ Hits        15626    15954     +328     
- Misses        919      957      +38     
- Partials      417      418       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@charles-cooper charles-cooper marked this pull request as ready for review January 20, 2025 17:17
@charles-cooper charles-cooper added this to the v0.4.1 milestone Jan 20, 2025
@cyberthirst cyberthirst added the release - must release blocker label Jan 20, 2025
@cyberthirst
Copy link
Copy Markdown
Collaborator

let's also update the docs please

assert warnings_control is None # sanity
warnings_filter = "default"

if warnings_control is not None:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why not reset also for None?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

None indicates to not touch warnings settings, but resetwarnings() modifies the global filter

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what's the point of allowing None if should be nop? also, is it possible to use the compiler as a library, once providing a warnings flag, once not, and thus (incorrectly) reusing the settings from the previous run?

Copy link
Copy Markdown
Member Author

@charles-cooper charles-cooper Feb 19, 2025

Choose a reason for hiding this comment

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

what's the point of allowing None if should be nop?

the point is allowing None is it makes the signature generic, you don't need to check it in the caller

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

also, is it possible to use the compiler as a library, once providing a warnings flag, once not, and thus (incorrectly) reusing the settings from the previous run?

yea -- i refactored so it restores the original warnings filter, see 4d64b86

@cyberthirst
Copy link
Copy Markdown
Collaborator

as per our offline discussion we might want to propage the flags to the Settings obj

@cyberthirst
Copy link
Copy Markdown
Collaborator

cyberthirst commented Feb 18, 2025

set_warnings_filter is called from at the beginning of compile_files and we load settings from an archive only later on. so i think it will be set incorrectly when compiling archives

also there aren't any tests for exactly these scenarios - let's please add tests to cover the extensions of the Settings obj

settings: Optional[Settings] = None,
storage_layout_paths: list[str] = None,
no_bytecode_metadata: bool = False,
warnings_control: Optional[str] = None,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

unused

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it's used by the decorator!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nvm, posted this before reading context

@charles-cooper charles-cooper merged commit 305813c into vyperlang:master Feb 21, 2025
161 checks passed
@charles-cooper charles-cooper deleted the feat/warnings-filter branch February 21, 2025 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release - must release blocker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants