【備忘録】VScodeにPythonのLintを設定する
PythonでのコーディングをVScodeを使ってやってみることにしてみました。
これに伴って環境の整理をしていましたが、lintの設定をすることにしてみました。
lintに何を使うか、fake8
標準の機能としてPylintが有効になっているところを、fake8を使ってみることにします
手順
- flake8をインストール
pip install flake8
- コードフォーマッターにautopep8をインストール、自動でコードを整形してくれます
pip install autopep8
"python.linting.pylintEnabled": false, // pylintを止めます "python.linting.flake8Enabled": true, // flake8を動かします "python.linting.lintOnSave": true, // pythonのlintが、pythonファイルの保存時に動くようにします "python.linting.flake8Args": [ // 無視する内容を設定します ], "python.formatting.provider": "autopep8", "python.formatting.autopep8Args": [ "--aggressive" ], // ファイルの自動保存の設定になります "files.autoSave": "afterDelay", "files.autoSaveDelay": 10000,
以上です。
参考
新しいプロジェクトを開始しました
社会人になる前に、友人と企画してブラッシュアップしていた企画がありました。
その企画は、いくつかのITベンチャー企業の方にプレゼンさせていただきました。
またそのうちの一社では社員の方と一緒に企画を練ったり、実装をしたりしていきました。
結果的にその企画は途中でボツになり、他の企画に移り変わってしまったのですが、本当に実現したい企画だったので時々実装プランを練ったりしていました。
ここしばらくその企画についてはすっかり忘れていて、他のプロジェクトに夢中になっていました。
しかし、ここ最近ふつふつと、今度こそ実現したいという思いが、良い温度で湧き上がり、一定の水準をキープし続けています。
ものすごい勢いがあるわけではないですが、なんとも今までにない落ち着いたワクワク感があります。
せっかくなので、実現してみたいなと思い、プロジェクトを走らせはじめました。
今度は頓挫させないように、低コスト・低カロリーで、こだわりは持たずにリリースまで持っていこうかなと思います。
そんな、ポエムでもない、お話をさせていただきました。
【備忘録】Flutter で build_runner を使い flutter pub run build_runner build をしたときに、 Failed to precompile build_runner:build_runner といったエラーが出る場合の対応
環境
ProductName: Mac OS X ProductVersion: 10.15.7 BuildVersion: 19H1030
Flutter: 2.2.0 build_runner: 2.0.2
エラーについて
$ flutter pub run build_runner build Failed to precompile build_runner:build_runner: ../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:1600:40: Error: Getter not found: 'topLevelVariable'. return kinds.contains(TargetKind.topLevelVariable); ^^^^^^^^^^^^^^^^ ../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2024:23: Error: Getter not found: 'topLevelVariable'. case TargetKind.topLevelVariable: ^^^^^^^^^^^^^^^^ ../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2024:23: Error: Type 'dynamic' of the case expression is not a subtype of type 'TargetKind' of this switch expression. - 'TargetKind' is from 'package:meta/meta_meta.dart' ('../../../.pub-cache/hosted/pub.dartlang.org/meta-1.3.0/lib/meta_meta.dart'). case TargetKind.topLevelVariable: ^ ../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2001:13: Context: The switch expression is here. switch (this) { ^ pub finished with exit code 1
対応
$ flutter packages pub upgrade
vscodeだと以下をクリックしてもできます
参考
https://github.com/dart-lang/build/issues/1676#issuecomment-458056325
【備忘録】記事を書くときに便利なコマンド、Max OSのバージョンを sw_vers コマンドで確認する
技術系の記事を書くときには、検証をした環境・再現できる環境などを書いてあげることが大切なことかと思います。
mac OSだと、 画面の左上のリンゴマーク
> About This Mac
から確認することもできますが、コマンドで簡単にしてしまいたいときに、 sw_vers
コマンドが利用できます。
$ sw_vers ProductName: Mac OS X ProductVersion: 10.15.7 BuildVersion: 19H1030
おそらく soft ware version s の sw_versかなと。
それ以外の mac OS の Utility コマンドは以下にまとめられています。
よく使う pbcopy
pbpaste
も同じ Utilityコマンドです。
【備忘録】mac OS Catalina(10.15.7)で brew install をしたら Error: Permission denied @ apply2files というエラーが出た際の対応
経緯
brew install
や brew upgrade
などをした際に、以下のエラーが表示されてしまった
エラー内容
Error: Permission denied @ apply2files - /usr/local/lib/docker/cli-plugins
うまくいった対応
$ sudo chown -R $(whoami) $(brew --prefix)/*
コマンドの意味
brewコマンドでのインストール先のファイル・ディレクトリの所有者を現在のユーザーに変更します
細かく調査
実際にコマンドを打ってみたらすぐわかりました
brew --prefix
$(brew --prefix)/*
- brewコマンドでのインストール先のファイルたちを指定
whoami
- 現在のユーザー名を表示
chown -R
man chown
をすると書いてありましたThe chown utility changes the user ID and/or the group ID of the specified files. Symbolic links named by arguments are silently left unchanged unless -h is used.
-R
についてはChange the user ID and/or the group ID for the file hierarchies rooted in the files instead of just the files themselves.
- 要するに指定したファイル以下のファイルのユーザーIDやグループIDを再帰的に変更
ちなみに
sudo brew
はもうダメみたいでした
Error: Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system.
gitでタグをチェックアウトする
gitを使ってバージョンコントロールをする上で、GitHubのRelease機能を利用したりしてgitのtagは作成したものの、そのtagを打った際のコードに戻る(チェックアウトする)ことが少なかったので、その方法などを改めて確認しておきます。
タグ一覧を確認
git tag
このコマンドで作成されたタグが一覧になって表示されます
対象のタグをチェックアウト
git checkout -b branchName refs/tags/tagName
ついでに、現在のブランチの最新コミットでタグ作成方法
git tag tagName
タグにコメントを付ける場合
git tag -a tagName -m 'comment'
↓の場合、コメント入力画面が表示されます
git tag -a tagName
過去のコミットでタグを作成する場合
git tag -a tagName -m 'comment' xxxxxxx
作成したタグをリモートリポジトリにPushする方法
git push origin tagName
複数の場合
git push origin --tags
タグを削除する場合
git tag -d tagName
Push済の、リポジトリにあるタグを削除する場合
git push origin :refs/tags/tagName もしくは git push --delete origin refs/tags/tagName
Angular で Webアプリケーションを作成する為に、MacOS上にAngular CLIで開発環境を構築する為の備忘録
Angular CLI とは
Angular を使って開発をする為の、コマンドラインツールです。Angularを使う場合には基本的にこれを用いることになるかと思いますが、メリットは色々あります。
Angular CLI をインストールする方法
npm install -g @angular/cli
メモ: Angular CLI を npm install しようとしたら、EEXIST: file already exists .... といったエラーが出た場合の対応
今回バージョンは次のものになります
@angular/cli@10.0.1
プロジェクトを作成する
プロジェクト名を決める
今回はよくあるものですが my-app
にしてみます
コマンド
% ng new my-app
↑のコマンドを叩くと、↓のような質問プロンプトが表示されます。 これに答えてきます。
? Would you like to add Angular routing? (y/N) ? Which stylesheet format would you like to use? (Use arrow keys) ❯ CSS SCSS [ https://sass-lang.com/documentation/syntax#scss ] Sass [ https://sass-lang.com/documentation/syntax#the-indented-syntax ] Less [ http://lesscss.org ] Stylus [ http://stylus-lang.com ]
すると、以下のようなファイルたちが生成されていきます。
CREATE probless/README.md (1026 bytes) CREATE probless/.editorconfig (274 bytes) CREATE probless/.gitignore (631 bytes) CREATE probless/angular.json (3670 bytes) CREATE probless/package.json (1258 bytes) CREATE probless/tsconfig.base.json (458 bytes) CREATE probless/tsconfig.json (475 bytes) CREATE probless/tslint.json (3184 bytes) CREATE probless/.browserslistrc (852 bytes) CREATE probless/karma.conf.js (1020 bytes) CREATE probless/tsconfig.app.json (292 bytes) CREATE probless/tsconfig.spec.json (338 bytes) CREATE probless/src/favicon.ico (948 bytes) CREATE probless/src/index.html (294 bytes) CREATE probless/src/main.ts (372 bytes) CREATE probless/src/polyfills.ts (2835 bytes) CREATE probless/src/styles.styl (80 bytes) CREATE probless/src/test.ts (753 bytes) CREATE probless/src/assets/.gitkeep (0 bytes) CREATE probless/src/environments/environment.prod.ts (51 bytes) CREATE probless/src/environments/environment.ts (662 bytes) CREATE probless/src/app/app-routing.module.ts (246 bytes) CREATE probless/src/app/app.module.ts (393 bytes) CREATE probless/src/app/app.component.styl (0 bytes) CREATE probless/src/app/app.component.html (25757 bytes) CREATE probless/src/app/app.component.spec.ts (1065 bytes) CREATE probless/src/app/app.component.ts (213 bytes) CREATE probless/e2e/protractor.conf.js (869 bytes) CREATE probless/e2e/tsconfig.json (299 bytes) CREATE probless/e2e/src/app.e2e-spec.ts (641 bytes) CREATE probless/e2e/src/app.po.ts (301 bytes) ⠼ Installing packages... ✔ Packages installed successfully. Successfully initialized git.
プロジェクトを動かす
$ cd my-app $ ng serve
↑のコマンドを叩くと、以下のようなテキストが表示されます。
Compiling @angular/animations : es2015 as esm2015 Compiling @angular/core : es2015 as esm2015 Compiling @angular/compiler/testing : es2015 as esm2015 Compiling @angular/animations/browser : es2015 as esm2015 Compiling @angular/core/testing : es2015 as esm2015 Compiling @angular/common : es2015 as esm2015 Compiling @angular/platform-browser : es2015 as esm2015 Compiling @angular/common/http : es2015 as esm2015 Compiling @angular/common/testing : es2015 as esm2015 Compiling @angular/animations : es2015 as esm2015 Compiling @angular/core : es2015 as esm2015 Compiling @angular/compiler/testing : es2015 as esm2015 Compiling @angular/animations/browser : es2015 as esm2015 Compiling @angular/core/testing : es2015 as esm2015 Compiling @angular/common : es2015 as esm2015Compiling @angular/platform-browser-dynamic : es2015 as esm2015 Compiling @angular/platform-browser/testing : es2015 as esm2015 Compiling @angular/router : es2015 as esm2015 Compiling @angular/animations/browser/testing : es2015 as esm2015 Compiling @angular/common/http/testing : es2015 as esm2015 Compiling @angular/forms : es2015 as esm2015 Compiling @angular/platform-browser/animations : es2015 as esm2015 Compiling @angular/platform-browser-dynamic/testing : es2015 as esm2015 Compiling @angular/router/testing : es2015 as esm2015 chunk {main} main.js, main.js.map (main) 60.6 kB [initial] [rendered] chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 141 kB [initial] [rendered] chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered] chunk {styles} styles.js, styles.js.map (styles) 12.9 kB [initial] [rendered] chunk {vendor} vendor.js, vendor.js.map (vendor) 2.64 MB [initial] [rendered] Date: 2020-07-09T08:47:41.158Z - Hash: 485f10dac3e8cce82aab - Time: 8120ms ** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ ** : Compiled successfully.
続々とコンパイルされていき、 localhost:4200
でブラウザから確認できる様になります。
一旦、これで開発できる環境は整いました。