Skip to content

Conversation

@adriangb
Copy link
Contributor

@adriangb adriangb commented Jul 9, 2023

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Jul 9, 2023

Codecov Report

Merging #45 (0e08eca) into main (0ad1bd8) will increase coverage by 0.24%.
The diff coverage is 96.15%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main      #45      +/-   ##
==========================================
+ Coverage   94.25%   94.50%   +0.24%     
==========================================
  Files           2        2              
  Lines         174      200      +26     
  Branches       27       29       +2     
==========================================
+ Hits          164      189      +25     
- Misses          8        9       +1     
  Partials        2        2              
Impacted Files Coverage Δ
annotated_types/__init__.py 91.72% <95.00%> (+0.57%) ⬆️
annotated_types/test_cases.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@adriangb adriangb mentioned this pull request Jul 9, 2023
Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

Seems reasonable; it won't actually help Hypothesis but nor will it hurt and it's simple to explain and implement.

  • Consider defining Predicate.__invert__ so we can write ~Predicate[fn] as sugar for Predicate[Not[fn]]?
  • I'd favor runtime checks (if __debug__:) that (a) whatever Not[...] wraps is a callable and not an instance of BaseMetadata, and (b) that whatever non-Predicate BaseMetadata classes wrap is not a Not. Seems kinda silly, but it's the kind of thing that can avoid a surprising amount of pain later. Perf impact seems small, but maybe we really care about it anyway 🤔

@adriangb
Copy link
Contributor Author

adriangb commented Jul 17, 2023

I'd favor runtime checks (if debug:) that (a) whatever Not[...] wraps is a callable and not an instance of BaseMetadata, and (b) that whatever non-Predicate BaseMetadata classes wrap is not a Not. Seems kinda silly, but it's the kind of thing that can avoid a surprising amount of pain later. Perf impact seems small, but maybe we really care about it anyway 🤔

Do you mean that we check to prohibit Not[Predicate[...]] and only allow Predicate[Not[...]]?

@Zac-HD
Copy link
Member

Zac-HD commented Jul 17, 2023

Either of those seem fine, but I'd ban eg Not[Ge(5)] and MinLen([Not[3]).

@adriangb
Copy link
Contributor Author

MinLen([Not[3])

Won't this already be rejected by type checkers? Not requires a callable and 3 is not a callable. Similarly MinLen requires an int as the first argument and Not is not anint.

@Zac-HD
Copy link
Member

Zac-HD commented Jul 17, 2023

Yeah, seems fine to rely on static type checking if we expect users to have that.

@adriangb
Copy link
Contributor Author

I think that’s a fair bet and I’d rather rely on that than adding more runtime type checking here.

@adriangb adriangb merged commit 726ab13 into annotated-types:main Jul 17, 2023
@adriangb adriangb deleted the add-negated-predicate branch July 17, 2023 20:11
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.

3 participants