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

Enable null safety #472

Merged
merged 1 commit into from
Sep 29, 2020
Merged

Enable null safety #472

merged 1 commit into from
Sep 29, 2020

Conversation

kevmoo
Copy link
Member

@kevmoo kevmoo commented Sep 24, 2020

No description provided.

@kevmoo
Copy link
Member Author

kevmoo commented Sep 24, 2020

Sadly, test/streamed_request_test.dart is failing on safari – but all of the other tests are passing

var pairs = <List<String>>[];
map.forEach((key, value) => pairs.add([
Uri.encodeQueryComponent(key, encoding: encoding),
Uri.encodeQueryComponent(value, encoding: encoding)
Uri.encodeQueryComponent(key, encoding: encoding ?? utf8),
Copy link
Member Author

Choose a reason for hiding this comment

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

Uri.encodeQueryComponent encoding param is now non-null with a default.

So we have to hoist the default value here for a null encoding

unawaited(xhr.onLoad.first.then((_) {
// TODO(nweiz): Set the response type to "arraybuffer" when issue 18542
Copy link
Member Author

Choose a reason for hiding this comment

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

This issue is now closed

// TODO(nweiz): Set the response type to "arraybuffer" when issue 18542
// is fixed.
var blob = xhr.response as Blob ?? Blob([]);
var blob = xhr.response as Blob;
Copy link
Member Author

Choose a reason for hiding this comment

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

According to the annotations on the dart:html types, response is never null.

Copy link
Member

Choose a reason for hiding this comment

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

What do you mean by this? I think it probably is true that if onLoad.first doesn't have an error this would be non-null, but I don't know what you mean by "the annotations on the dart:html types".

@@ -52,16 +52,17 @@ class BrowserClient extends BaseClient {
request.headers.forEach(xhr.setRequestHeader);

var completer = Completer<StreamedResponse>();

// TODO(kevmoo): not sure what to do here...
// ignore: void_checks
Copy link
Member Author

Choose a reason for hiding this comment

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

Here and below – not sure why we're getting this void_checks hint...

Copy link
Member

Choose a reason for hiding this comment

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

This will be worked around by googlearchive/pedantic#69 if we get that in.

This issue looks like https://github.com/dart-lang/linter/issues/2185

I think we can keep the lint and point the todo at that issue.

lib/src/base_request.dart Outdated Show resolved Hide resolved
pubspec.yaml Outdated
@@ -1,15 +1,19 @@
name: http
version: 0.12.2
version: 0.12.3-nullsafety
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we are generally going with breaking changes for non-allow-listed packages, although that isn't totally decided

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh it sounds like from the changelog entry this is in the allow list, even so we really only don't want to do breaking changes for flutter depended on packages.

Copy link
Member Author

Choose a reason for hiding this comment

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

Flutter doesn't depend on this directly – at least I don't think so.

A lot of stuff in the Flutter ecosystem does, though...

Copy link
Contributor

Choose a reason for hiding this comment

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

cc @natebosch I would still do a major version bump.

We need to stop setting a bad example here.

Copy link
Member

Choose a reason for hiding this comment

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

Oh it sounds like from the changelog entry this is in the allow list

It isn't.

I would still do a major version bump.

+1. We'll want a breaking change for #424 in any case. I can try to get to that next week so we can make a decision before we need to publish this.

@kevmoo
Copy link
Member Author

kevmoo commented Sep 25, 2020

where are we on this review, kind sirs?

CHANGELOG.md Outdated Show resolved Hide resolved
linter:
rules:
- annotate_overrides
- avoid_bool_literals_in_conditional_expressions
- avoid_catching_errors
Copy link
Member

Choose a reason for hiding this comment

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

Enabling lints is not related to null safety and should go in a separate PR.

@@ -10,7 +10,7 @@
///
/// [RFC 2046]: http://tools.ietf.org/html/rfc2046#section-5.1.1.
/// [RFC 1521]: https://tools.ietf.org/html/rfc1521#section-4
const List<int> BOUNDARY_CHARACTERS = <int>[
const List<int> boundaryCharacters = <int>[
Copy link
Member

Choose a reason for hiding this comment

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

use a separate PR.

@@ -52,16 +52,17 @@ class BrowserClient extends BaseClient {
request.headers.forEach(xhr.setRequestHeader);

var completer = Completer<StreamedResponse>();

// TODO(kevmoo): not sure what to do here...
// ignore: void_checks
Copy link
Member

Choose a reason for hiding this comment

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

This will be worked around by googlearchive/pedantic#69 if we get that in.

This issue looks like https://github.com/dart-lang/linter/issues/2185

I think we can keep the lint and point the todo at that issue.

// TODO(nweiz): Set the response type to "arraybuffer" when issue 18542
// is fixed.
var blob = xhr.response as Blob ?? Blob([]);
var blob = xhr.response as Blob;
Copy link
Member

Choose a reason for hiding this comment

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

What do you mean by this? I think it probably is true that if onLoad.first doesn't have an error this would be non-null, but I don't know what you mean by "the annotations on the dart:html types".

pubspec.yaml Outdated Show resolved Hide resolved
@kevmoo
Copy link
Member Author

kevmoo commented Sep 29, 2020

PTAL – cleaned things up

@jakemac53
Copy link
Contributor

Please don't force push because now we can no longer see what you changed compared to our last review :(

@kevmoo
Copy link
Member Author

kevmoo commented Sep 29, 2020 via email

@kevmoo kevmoo merged commit 20e3a59 into master Sep 29, 2020
@kevmoo kevmoo deleted the null_safety branch September 29, 2020 16:42
@jhancock4d
Copy link

Is there a beta package with this enabled available? I can't find it and this is blocking in almost any project to being able to safely turn on null safety.

@natebosch
Copy link
Member

Publishing is tracked in #501 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants