Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9ec5324

Browse files
cjqianLIT team
authored andcommitted
Rename URL to URLLitType in the front end.
PiperOrigin-RevId: 465069771
1 parent 853edd0 commit 9ec5324

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

lit_nlp/api/types.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class TopTokens(_StringCandidateList):
171171

172172

173173
@attr.s(auto_attribs=True, frozen=True, kw_only=True)
174-
class URL(TextSegment):
174+
class URLLitType(TextSegment):
175175
"""TextSegment that should be interpreted as a URL."""
176176
pass
177177

@@ -516,9 +516,8 @@ class InfluentialExamples(LitType):
516516
# LINT.ThenChange(../client/lib/lit_types.ts)
517517

518518
# Type aliases for backend use.
519-
# `Boolean` and `String` are existing datatypes in TypeScript, so `Boolean` and
520-
# `String` LitTypes are serialized and instantiated as `BooleanLitType` and
521-
# `StringLitType`, respectively, to avoid collisions with language features on
522-
# the front-end.
519+
# The following names are existing datatypes in TypeScript, so we add a
520+
# `LitType` suffix to avoid collisions with language features on the front-end.
523521
Boolean = BooleanLitType
524522
String = StringLitType
523+
URL = URLLitType

lit_nlp/client/elements/annotated_text_vis.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {computed, observable} from 'mobx';
1313

1414
import {getVizColor} from '../lib/colors';
1515
import {ReactiveElement} from '../lib/elements';
16+
import {URLLitType} from '../lib/lit_types';
1617
import {styles as sharedStyles} from '../lib/shared_styles.css';
1718
import {formatSpanLabel, SpanLabel} from '../lib/types';
1819

@@ -194,7 +195,7 @@ export class AnnotatedTextVis extends ReactiveElement {
194195
renderTextSegment(name: string) {
195196
const text = this.segments[name];
196197
const spans = this.activeAnnotations[name];
197-
const isURL = this.segmentSpec[name].__name__ === 'URL';
198+
const isURL = this.segmentSpec[name] instanceof URLLitType;
198199
return html`
199200
<div class='group'>
200201
<div class='group-title'>${name}</div>

lit_nlp/client/lib/lit_types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export class TopTokens extends _StringCandidateList {
144144
* TextSegment that should be interpreted as a URL.
145145
*/
146146
@registered
147-
export class URL extends TextSegment {
147+
export class URLLitType extends TextSegment {
148148
}
149149

150150
/**

lit_nlp/client/modules/datapoint_editor_module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {styleMap} from 'lit/directives/style-map';
2626
import {computed, observable, when} from 'mobx';
2727
import {app} from '../core/app';
2828
import {LitModule} from '../core/lit_module';
29-
import {BooleanLitType, EdgeLabels, ImageBytes, ListLitType, LitTypeWithVocab, MultiSegmentAnnotations, SpanLabels, SparseMultilabel, StringLitType} from '../lib/lit_types';
29+
import {BooleanLitType, EdgeLabels, ImageBytes, ListLitType, LitTypeWithVocab, MultiSegmentAnnotations, SpanLabels, SparseMultilabel, StringLitType, URLLitType} from '../lib/lit_types';
3030
import {styles as sharedStyles} from '../lib/shared_styles.css';
3131
import {AnnotationCluster, defaultValueByField, EdgeLabel, formatAnnotationCluster, formatEdgeLabel, formatSpanLabel, IndexedInput, Input, ModelInfoMap, SCROLL_SYNC_CSS_CLASS, SpanLabel, Spec} from '../lib/types';
3232
import {findSpecKeys, isLitSubtype} from '../lib/utils';
@@ -586,7 +586,7 @@ export class DatapointEditorModule extends LitModule {
586586
this.appState.currentModelRequiredInputSpecKeys.includes(key);
587587

588588
let headerContent = html`${isRequiredModelInput ? '*' : ''}${key}`;
589-
if (isLitSubtype(fieldSpec, 'URL')) {
589+
if (fieldSpec instanceof URLLitType) {
590590
headerContent = html`
591591
<a href=${value as string} target="_blank">
592592
${headerContent}

0 commit comments

Comments
 (0)