8000 pull-pylance-with-pyright-1.1.266 (#3816) · codean-io/scip-python@ed13daf · GitHub
[go: up one dir, main page]

Skip to content

Commit ed13daf

Browse files
authored
pull-pylance-with-pyright-1.1.266 (#3816)
1 parent 75a38eb commit ed13daf

File tree

3 files changed

+30
-29
lines changed

3 files changed

+30
-29
lines changed

packages/pyright-internal/src/analyzer/docStringConversion.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const HtmlEscapes: RegExpReplacement[] = [
8585
{ exp: />/g, replacement: '>' },
8686
];
8787

88+
const MarkdownLineBreak = ' \n';
8889
// http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#literal-blocks
8990
const LiteralBlockEmptyRegExp = /^\s*::$/;
9091
const LiteralBlockReplacements: RegExpReplacement[] = [
@@ -262,23 +263,23 @@ class DocStringConverter {
262263
if (
263264
currIndent > prevIndent &&
264265
!_isUndefinedOrWhitespace(prev) &&
265-
!this._builder.endsWith('\\\n') &&
266+
!this._builder.endsWith(MarkdownLineBreak) &&
266267
!this._builder.endsWith('\n\n') &&
267268
!_isHeader(prev)
268269
) {
269-
this._builder = this._builder.slice(0, -1) + '\\\n';
270+
this._builder = this._builder.slice(0, -1) + MarkdownLineBreak;
270271
}
271272

272273
if (
273274
prevIndent > currIndent &&
274275
!_isUndefinedOrWhitespace(prev) &&
275-
!this._builder.endsWith('\\\n') &&
276+
!this._builder.endsWith(MarkdownLineBreak) &&
276277
!this._builder.endsWith('\n\n')
277278
) {
278-
this._builder = this._builder.slice(0, -1) + '\\\n';
279+
this._builder = this._builder.slice(0, -1) + MarkdownLineBreak;
279280
}
280281

281-
if (prevIndent === 0 || this._builder.endsWith('\\\n') || this._builder.endsWith('\n\n')) {
282+
if (prevIndent === 0 || this._builder.endsWith(MarkdownLineBreak) || this._builder.endsWith('\n\n')) {
282283
line = this._convertIndent(line);
283284
} else {
284285
line = line.trimStart();
@@ -579,8 +580,8 @@ class DocStringConverter {
579580
if (hasOddNumColons || restDirective) {
580581
const prev = this._lineAt(this._lineNum - 1);
581582
// Force a line break, if previous line doesn't already have a break or is blank
582-
if (!this._builder.endsWith(`\\\n`) && !this._builder.endsWith(`\n\n`) && !_isHeader(prev)) {
583-
this._builder = this._builder.slice(0, -1) + '\\\n';
583+
if (!this._builder.endsWith(MarkdownLineBreak) && !this._builder.endsWith(`\n\n`) && !_isHeader(prev)) {
584+
this._builder = this._builder.slice(0, -1) + MarkdownLineBreak;
584585
}
585586

586587
// force indent for fields

packages/pyright-internal/src/tests/docStringConversion.test.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test('MarkdownIndention', () => {
3636
['A\n\nB', 'A\n\nB'],
3737
['A\n B', 'A\nB'],
3838
[' A\n B', 'A\nB'],
39-
['\nA\n B', 'A\\\n    B'],
39+
['\nA\n B', 'A \n    B'],
4040
['\n A\n B', 'A\nB'],
4141
['\nA\nB\n', 'A\nB'],
4242
[' \n\nA \n \nB \n ', 'A\n\nB'],
@@ -110,9 +110,9 @@ test('AsterisksAtStartOfArgs', () => {
110110

111111
const markdown = `Foo:
112112
113-
Args:\\
114-
    foo (Foo): Foo!\\
115-
    \\*args: These are positional args.\\
113+
Args:
114+
    foo (Foo): Foo!
115+
    \\*args: These are positional args.
116116
    \\*\\*kwargs: These are named args.
117117
`;
118118

@@ -128,7 +128,7 @@ test('CopyrightAndLicense', () => {
128128

129129
const markdown = `This is a test.
130130
131-
:copyright: Fake Name\\
131+
:copyright: Fake Name
132132
:license: ABCv123
133133
`;
134134

@@ -150,13 +150,13 @@ test('CommonRestFieldLists', () => {
150150

151151
const markdown = `This function does something.
152152
153-
:param foo: This is a description of the foo parameter\\
154-
    which does something interesting.\\
155-
:type foo: Foo\\
156-
:param bar: This is a description of bar.\\
157-
:type bar: Bar\\
158-
:return: Something else.\\
159-
:rtype: Something\\
153+
:param foo: This is a description of the foo parameter
154+
    which does something interesting.
155+
:type foo: Foo
156+
:param bar: This is a description of bar.
157+
:type bar: Bar
158+
:return: Something else.
159+
:rtype: Something
160160
:raises ValueError: If something goes wrong.
161161
`;
162162

@@ -557,8 +557,8 @@ keep_default_na : bool, default True
557557
558558
na_filter : bool, default True`;
559559

560-
const markdown = `Title\\
561-
keep\\_default\\_na : bool, default True\\
560+
const markdown = `Title
561+
keep\\_default\\_na : bool, default True
562562
    Whether or not to include the default NaN values when parsing the data.
563563
564564
* If \`keep_default_na\` is True, and \`na_values\` are specified, \`na_values\`
@@ -575,7 +575,7 @@ test('FieldListEpyText', () => {
575575
@param param1: description`;
576576

577577
const markdown = `
578-
1. Epytext:\\
578+
1. Epytext:
579579
     @param param1: description`;
580580

581581
_testConvertToMarkdown(docstring, markdown);
@@ -587,7 +587,7 @@ test('FieldListRest', () => {
587587
:param param1: description`;
588588

589589
const markdown = `
590-
2. reST:\\
590+
2. reST:
591591
     :param param1: description`;
592592

593593
_testConvertToMarkdown(docstring, markdown);
@@ -600,8 +600,8 @@ test('FieldListGoogleV1', () => {
600600
param1: description`;
601601

602602
const markdown = `
603-
3. Google (variant 1):\\
604-
     Args:\\
603+
3. Google (variant 1):
604+
     Args:
605605
         param1: description`;
606606

607607
_testConvertToMarkdown(docstring, markdown);
@@ -614,8 +614,8 @@ test('FieldListGoogleV2', () => {
614614
param1 (type): description`;
615615

616616
const markdown = `
617-
4. Google (variant 2):\\
618-
     Args:\\
617+
4. Google (variant 2):
618+
     Args:
619619
         param1 (type): description`;
620620

621621
_testConvertToMarkdown(docstring, markdown);
@@ -692,7 +692,7 @@ find an arbitrary function's zeros.
692692
693693
@type b: number
694694
695-
@param b: The y intercept of the line. The X{y intercept} of a\\
695+
@param b: The y intercept of the line. The X{y intercept} of a
696696
            line is the point at which it crosses the y axis (M{x=0}).
697697
698698
@rtype: number

packages/pyright-internal/src/tests/fourslash/hover.docstring.links.fourslash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
//// [|/*marker1*/func|]()
99

1010
helper.verifyHover('markdown', {
11-
marker1: '```python\n(function) func: () -> None\n```\n---\n\\\nsomething [link](http://microsoft.com) something',
11+
marker1: '```python\n(function) func: () -> None\n```\n---\nsomething [link](http://microsoft.com) something',
1212
});

0 commit comments

Comments
 (0)
0