Skip to content

Commit

Permalink
Add missing abstract modifier to classes (bokeh#14048)
Browse files Browse the repository at this point in the history
* Add missing `abstract` modifier to classes

* Don't instantiate abstract classes
  • Loading branch information
mattpap authored Sep 3, 2024
1 parent a28073d commit 78dcbf3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bokehjs/src/lib/core/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export namespace View {

export type IterViews<T extends View = View> = Generator<T, void, undefined>

export class View implements ISignalable, Equatable {
export abstract class View implements ISignalable, Equatable {
readonly removed = new Signal0<this>(this, "removed")

readonly model: HasProps
Expand Down
2 changes: 1 addition & 1 deletion bokehjs/src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export namespace Model {

export interface Model extends Model.Attrs {}

export class Model extends HasProps {
export abstract class Model extends HasProps {
declare properties: Model.Props

private /*readonly*/ _js_callbacks: Map<string, (() => void)[]>
Expand Down
6 changes: 2 additions & 4 deletions bokehjs/src/lib/models/axes/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type TickCoords = {
minor: Coords
}

export class AxisView extends GuideRendererView {
export abstract class AxisView extends GuideRendererView {
declare model: Axis
declare visuals: Axis.Visuals

Expand Down Expand Up @@ -772,7 +772,7 @@ export namespace Axis {

export interface Axis extends Axis.Attrs {}

export class Axis extends GuideRenderer {
export abstract class Axis extends GuideRenderer {
declare properties: Axis.Props
declare __view_type__: AxisView

Expand All @@ -781,8 +781,6 @@ export class Axis extends GuideRenderer {
}

static {
this.prototype.default_view = AxisView

this.mixins<Axis.Mixins>([
["axis_", mixins.Line],
["major_tick_", mixins.Line],
Expand Down
18 changes: 9 additions & 9 deletions bokehjs/test/unit/models/axes/axis.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {expect} from "assertions"
import {display} from "../../_util"

import {Axis} from "@bokehjs/models/axes/axis"
import {LinearAxis} from "@bokehjs/models/axes/linear_axis"
import {BasicTicker} from "@bokehjs/models/tickers/basic_ticker"
import {BasicTickFormatter} from "@bokehjs/models/formatters/basic_tick_formatter"
import {Plot} from "@bokehjs/models/plots/plot"
Expand All @@ -21,7 +21,7 @@ describe("Axis", () => {
})
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({
const axis = new LinearAxis({
ticker,
formatter,
major_label_overrides: new Map([[0, "zero"], [4, "four"], [10, "ten"]]),
Expand All @@ -41,7 +41,7 @@ describe("Axis", () => {
})
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({
const axis = new LinearAxis({
ticker,
formatter,
major_label_overrides: new Map<number, string | TeX>([[0, "zero"], [4, new TeX({text: "\\pi"})], [10, "$$ten$$"]]),
Expand All @@ -59,7 +59,7 @@ describe("Axis", () => {
it("should convert mathstrings on axis labels to TeX", async () => {
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({
const axis = new LinearAxis({
ticker,
formatter,
axis_label: "$$\\sin(x)$$",
Expand All @@ -80,7 +80,7 @@ describe("Axis", () => {
it("should convert mathstrings with line breaks in between delimiters on axis labels to TeX", async () => {
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({
const axis = new LinearAxis({
ticker,
formatter,
axis_label: `$$
Expand All @@ -107,7 +107,7 @@ describe("Axis", () => {
})
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({
const axis = new LinearAxis({
ticker,
formatter,
fixed_location: 10,
Expand All @@ -126,7 +126,7 @@ describe("Axis", () => {
})
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({
const axis = new LinearAxis({
ticker,
formatter,
fixed_location: "foo",
Expand All @@ -140,11 +140,11 @@ describe("Axis", () => {

describe("AxisView", () => {

async function build(axis_attrs: Partial<Axis.Attrs> = {}) {
async function build(axis_attrs: Partial<LinearAxis.Attrs> = {}) {
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()

const axis = new Axis({
const axis = new LinearAxis({
major_label_standoff: 11,
major_tick_out: 12,
ticker,
Expand Down
16 changes: 8 additions & 8 deletions bokehjs/test/unit/models/grids/grid.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {expect} from "assertions"
import {display} from "../../_util"

import {Axis} from "@bokehjs/models/axes/axis"
import {LinearAxis} from "@bokehjs/models/axes/linear_axis"
import {BasicTicker} from "@bokehjs/models/tickers/basic_ticker"
import {BasicTickFormatter} from "@bokehjs/models/formatters/basic_tick_formatter"
import {FixedTicker} from "@bokehjs/models/tickers/fixed_ticker"
Expand All @@ -18,7 +18,7 @@ describe("Grid", () => {
})
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({ticker, formatter, bounds: [2, 8]})
const axis = new LinearAxis({ticker, formatter, bounds: [2, 8]})
plot.add_layout(axis, "below")
const grid = new Grid({ticker})
plot.add_layout(grid, "center")
Expand All @@ -35,7 +35,7 @@ describe("Grid", () => {
})
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({ticker, formatter, bounds: [2, 8]})
const axis = new LinearAxis({ticker, formatter, bounds: [2, 8]})
plot.add_layout(axis, "left")
const grid = new Grid({ticker})
plot.add_layout(grid, "center")
Expand All @@ -52,7 +52,7 @@ describe("Grid", () => {
})
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({ticker, formatter, bounds: [2, 8]})
const axis = new LinearAxis({ticker, formatter, bounds: [2, 8]})
plot.add_layout(axis, "below")
const grid = new Grid({ticker, bounds: [1, 9]})
plot.add_layout(grid, "center")
Expand All @@ -69,7 +69,7 @@ describe("Grid", () => {
})
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({ticker, formatter})
const axis = new LinearAxis({ticker, formatter})
plot.add_layout(axis, "below")
const grid = new Grid({ticker})
plot.add_layout(grid, "center")
Expand All @@ -89,7 +89,7 @@ describe("Grid", () => {
})
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({ticker, formatter})
const axis = new LinearAxis({ticker, formatter})
plot.add_layout(axis, "below")
const grid = new Grid({ticker})
plot.add_layout(grid, "center")
Expand All @@ -109,7 +109,7 @@ describe("Grid", () => {
})
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({ticker, formatter})
const axis = new LinearAxis({ticker, formatter})
plot.add_layout(axis, "below")
const grid = new Grid({axis})
plot.add_layout(grid, "center")
Expand All @@ -130,7 +130,7 @@ describe("Grid", () => {

const axis_ticker = new FixedTicker({ticks: [1, 2, 3, 4]})
const formatter = new BasicTickFormatter()
const axis = new Axis({ticker: axis_ticker, formatter})
const axis = new LinearAxis({ticker: axis_ticker, formatter})

plot.add_layout(axis, "below")
const ticker = new BasicTicker()
Expand Down

0 comments on commit 78dcbf3

Please sign in to comment.