Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Stop depending on pkg:charcode and pkg:pedantic. #191

Merged
merged 7 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
include: package:pedantic/analysis_options.yaml
include: package:lints/recommended.yaml

analyzer:
strong-mode:
implicit-casts: false
lrhn marked this conversation as resolved.
Show resolved Hide resolved
errors:
todo: ignore
# Lint provided by pkg:pedantic – should fix this!
unawaited_futures: ignore
enable-experiment:
- non-nullable

linter:
rules:
- prefer_typing_uninitialized_variables
4 changes: 2 additions & 2 deletions lib/src/chunked_stream_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ChunkedStreamReader<T> {
}
_reading = true;

final substream = () async* {
Stream<List<T>> substream() async* {
// While we have data to read
while (size > 0) {
// Read something into the buffer, if buffer has been consumed.
Expand Down Expand Up @@ -158,7 +158,7 @@ class ChunkedStreamReader<T> {
yield output;
}
}
};
}

final c = StreamController<List<T>>();
c.onListen = () => c.addStream(substream()).whenComplete(c.close);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/stream_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class StreamGroup<T> implements Sink<Stream<T>> {
Stream<void> get onIdle =>
(_onIdleController ??= StreamController.broadcast()).stream;

StreamController<Null>? _onIdleController;
StreamController<void>? _onIdleController;

/// Streams that have been added to the group, and their subscriptions if they
/// have been subscribed to.
Expand Down Expand Up @@ -169,7 +169,7 @@ class StreamGroup<T> implements Sink<Stream<T>> {
/// [StreamSubscription.cancel]'s return value. Otherwise, it returns `null`.
Future? remove(Stream<T> stream) {
var subscription = _subscriptions.remove(stream);
var future = subscription == null ? null : subscription.cancel();
var future = subscription?.cancel();

if (_subscriptions.isEmpty) {
_onIdleController?.add(null);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/stream_sink_transformer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ abstract class StreamSinkTransformer<S, T> {
/// This means that calls to [StreamSink.add] on the returned sink may throw a
/// [TypeError] if the argument type doesn't match the reified type of the
/// sink.
@deprecated
@Deprecated("Will be removed in future version")
// TODO remove TypeSafeStreamSinkTransformer
static StreamSinkTransformer<S, T> typed<S, T>(
StreamSinkTransformer transformer) =>
Expand Down
5 changes: 4 additions & 1 deletion lib/src/stream_sink_transformer/reject_errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ class RejectErrorsSink<T> implements StreamSink<T> {
if (_closed) return done;
_closed = true;

if (!_canceled) _doneCompleter.complete(_inner.close());
if (!_canceled) {
// ignore: void_checks
_doneCompleter.complete(_inner.close());
}
return done;
}

Expand Down
5 changes: 2 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: async
version: 2.8.2
version: 2.8.3

description: Utility functions and classes related to the 'dart:async' library.
repository: https://github.com/dart-lang/async
Expand All @@ -12,8 +12,7 @@ dependencies:
meta: ^1.1.7

dev_dependencies:
charcode: ^1.3.0
fake_async: ^1.2.0
pedantic: ^1.10.0
lints: ^1.0.0
stack_trace: ^1.10.0
test: ^1.16.0
2 changes: 1 addition & 1 deletion test/io_sink_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

@deprecated
@Deprecated("Tests deprecated functionality")
library io_sink_impl;

import 'dart:io';
Expand Down
2 changes: 2 additions & 0 deletions test/result/result_captureAll_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// ignore_for_file: file_names

import 'dart:async';
import 'dart:math' show Random;

Expand Down
2 changes: 2 additions & 0 deletions test/result/result_flattenAll_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// ignore_for_file: file_names

import 'package:async/async.dart';
import 'package:test/test.dart';

Expand Down
10 changes: 5 additions & 5 deletions test/sink_base_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

@deprecated
@Deprecated("Tests deprecated functionality")
library sink_base_test;

import 'dart:async';
import 'dart:convert';

import 'package:charcode/charcode.dart';
import 'package:test/test.dart';

import 'package:async/async.dart';

const int letterA = 0x41;

void main() {
// We don't explicitly test [EventSinkBase] because it shares all the relevant
// implementation with [StreamSinkBase].
Expand Down Expand Up @@ -54,7 +55,6 @@ void main() {
var controller = StreamController<int>();
var addStreamCompleted = false;
sink.addStream(controller.stream).then((_) => addStreamCompleted = true);
;

await pumpEventQueue();
expect(addStreamCompleted, isFalse);
Expand Down Expand Up @@ -277,7 +277,7 @@ void main() {
var sink = _IOSink(onAdd: expectAsync1((data) {
expect(data, equals(utf8.encode('A')));
}));
sink.writeCharCode($A);
sink.writeCharCode(letterA);
});

test('respects the encoding', () async {
Expand All @@ -292,7 +292,7 @@ void main() {
test('throws if the sink is closed', () async {
var sink = _IOSink(onAdd: expectAsync1((_) {}, count: 0));
expect(sink.close(), completes);
expect(() => sink.writeCharCode($A), throwsStateError);
expect(() => sink.writeCharCode(letterA), throwsStateError);
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/stream_queue_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ void main() {
test('returns the result of closing the underlying subscription',
() async {
var controller =
StreamController<int>(onCancel: () => Future.value(42));
StreamController<int>(onCancel: () => Future<int>.value(42));
var events = StreamQueue<int>(controller.stream);
expect(await events.cancel(immediate: true), 42);
});
Expand Down
5 changes: 3 additions & 2 deletions test/subscription_transformer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ void main() {
group('with no callbacks', () {
test('forwards cancellation', () async {
var isCanceled = false;
var cancelCompleter = Completer();
var controller = StreamController(onCancel: expectAsync0(() {
var cancelCompleter = Completer<void>();
var controller =
StreamController(onCancel: expectAsync0<Future<void>>(() {
isCanceled = true;
return cancelCompleter.future;
}));
Expand Down